Prefer @SpringBootApplication-annotated class when finding main class
Closes gh-6496
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,6 +35,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class FindMainClass extends Task {
|
||||
|
||||
private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication";
|
||||
|
||||
private String mainClass;
|
||||
|
||||
private File classesRoot;
|
||||
@@ -70,10 +72,11 @@ public class FindMainClass extends Task {
|
||||
}
|
||||
try {
|
||||
if (this.classesRoot.isDirectory()) {
|
||||
return MainClassFinder.findSingleMainClass(this.classesRoot);
|
||||
return MainClassFinder.findSingleMainClass(this.classesRoot,
|
||||
SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot),
|
||||
"/");
|
||||
return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot), "/",
|
||||
SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new BuildException(ex);
|
||||
|
||||
Reference in New Issue
Block a user