Require single main class

Update run tasks to ensure that only a single main class is required
when performing a class search.

See gh-886
This commit is contained in:
Phillip Webb
2014-05-16 10:44:01 +01:00
parent 7c7d1f55e0
commit 7b170368e5
6 changed files with 86 additions and 34 deletions

View File

@@ -29,7 +29,7 @@ import org.springframework.boot.loader.tools.MainClassFinder;
/**
* Add a main class if one is missing from the build
*
*
* @author Dave Syer
*/
public class ComputeMain implements Action<Task> {
@@ -68,7 +68,7 @@ public class ComputeMain implements Action<Task> {
project.getLogger().debug(
"Looking for main in: " + main.getOutput().getClassesDir());
try {
String mainClass = MainClassFinder.findMainClass(main.getOutput()
String mainClass = MainClassFinder.findSingleMainClass(main.getOutput()
.getClassesDir());
project.getLogger().info("Computed main class: " + mainClass);
return mainClass;

View File

@@ -91,7 +91,7 @@ public class RunApp extends DefaultTask {
}
getLogger().info("Looking for main in: " + main.getOutput().getClassesDir());
try {
return MainClassFinder.findMainClass(main.getOutput().getClassesDir());
return MainClassFinder.findSingleMainClass(main.getOutput().getClassesDir());
}
catch (IOException ex) {
throw new IllegalStateException("Cannot find main class", ex);