Skip to content

Commit 8fe6969

Browse files
author
Dave Syer
committed
Delete duplicate logback.xml if running from Maven plugin
Fixes spring-projectsgh-143
1 parent ac34f9c commit 8fe6969

File tree

1 file changed

+9
-3
lines changed
  • spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven

1 file changed

+9
-3
lines changed

spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class RunMojo extends AbstractMojo {
8787
* the archive.
8888
*/
8989
@Parameter(defaultValue = "${project.build.outputDirectory}", required = true)
90-
private File classesDirectrory;
90+
private File classesDirectory;
9191

9292
@Override
9393
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -105,7 +105,7 @@ private final String getStartClass() throws MojoExecutionException {
105105
String mainClass = this.mainClass;
106106
if (mainClass == null) {
107107
try {
108-
mainClass = MainClassFinder.findMainClass(this.classesDirectrory);
108+
mainClass = MainClassFinder.findMainClass(this.classesDirectory);
109109
}
110110
catch (IOException ex) {
111111
throw new MojoExecutionException(ex.getMessage(), ex);
@@ -150,11 +150,17 @@ private void addResources(List<URL> urls) throws MalformedURLException {
150150
for (Resource resource : this.project.getResources()) {
151151
urls.add(new File(resource.getDirectory()).toURI().toURL());
152152
}
153+
// Special case: this file causes logback to worry that it has been configured
154+
// twice, so remove it from the target directory...
155+
File logback = new File(this.classesDirectory, "logback.xml");
156+
if (logback.exists() && logback.canWrite()) {
157+
logback.delete();
158+
}
153159
}
154160
}
155161

156162
private void addProjectClasses(List<URL> urls) throws MalformedURLException {
157-
urls.add(this.classesDirectrory.toURI().toURL());
163+
urls.add(this.classesDirectory.toURI().toURL());
158164
}
159165

160166
private void addDependencies(List<URL> urls) throws MalformedURLException {

0 commit comments

Comments
 (0)