Prefer @SpringBootApplication-annotated class when finding main class

Closes gh-6496
This commit is contained in:
Andy Wilkinson
2016-11-29 15:37:04 +00:00
parent ba61faee5e
commit 1595286e04
8 changed files with 287 additions and 55 deletions

View File

@@ -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);