Delete duplicate logback.xml if running from Maven plugin
Fixes gh-143
This commit is contained in:
parent
ac34f9c993
commit
8fe696944a
|
@ -87,7 +87,7 @@ public class RunMojo extends AbstractMojo {
|
||||||
* the archive.
|
* the archive.
|
||||||
*/
|
*/
|
||||||
@Parameter(defaultValue = "${project.build.outputDirectory}", required = true)
|
@Parameter(defaultValue = "${project.build.outputDirectory}", required = true)
|
||||||
private File classesDirectrory;
|
private File classesDirectory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||||
|
@ -105,7 +105,7 @@ public class RunMojo extends AbstractMojo {
|
||||||
String mainClass = this.mainClass;
|
String mainClass = this.mainClass;
|
||||||
if (mainClass == null) {
|
if (mainClass == null) {
|
||||||
try {
|
try {
|
||||||
mainClass = MainClassFinder.findMainClass(this.classesDirectrory);
|
mainClass = MainClassFinder.findMainClass(this.classesDirectory);
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new MojoExecutionException(ex.getMessage(), ex);
|
throw new MojoExecutionException(ex.getMessage(), ex);
|
||||||
|
@ -150,11 +150,17 @@ public class RunMojo extends AbstractMojo {
|
||||||
for (Resource resource : this.project.getResources()) {
|
for (Resource resource : this.project.getResources()) {
|
||||||
urls.add(new File(resource.getDirectory()).toURI().toURL());
|
urls.add(new File(resource.getDirectory()).toURI().toURL());
|
||||||
}
|
}
|
||||||
|
// Special case: this file causes logback to worry that it has been configured
|
||||||
|
// twice, so remove it from the target directory...
|
||||||
|
File logback = new File(this.classesDirectory, "logback.xml");
|
||||||
|
if (logback.exists() && logback.canWrite()) {
|
||||||
|
logback.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProjectClasses(List<URL> urls) throws MalformedURLException {
|
private void addProjectClasses(List<URL> urls) throws MalformedURLException {
|
||||||
urls.add(this.classesDirectrory.toURI().toURL());
|
urls.add(this.classesDirectory.toURI().toURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDependencies(List<URL> urls) throws MalformedURLException {
|
private void addDependencies(List<URL> urls) throws MalformedURLException {
|
||||||
|
|
Loading…
Reference in New Issue