Ignore non-JavaExec run task when finding application's main class

Previously, FindMainClassTask would look for a property named main
on any class named run. This was based on the assumption that the
run task would be a JavaExec task (typically provided by the
application plugin). If the run task was not a JavaExec task (more
accurately, if it did not have a main property) this would result in
a build failure due to trying to read a non-existent property.

This commit updates FindMainClassTask to only use the main property
of the run task if the task is a JavaExec task. This guarantees that
the property will exist on the task, and unlike using any property
named main on a task named run, also guarantee that its value will
refer to a Java class with a main method.

Closes gh-5501
This commit is contained in:
Andy Wilkinson
2016-03-29 11:03:47 +01:00
parent ae095b2c1b
commit 1043239de0
3 changed files with 54 additions and 11 deletions

View File

@@ -14,10 +14,17 @@ apply plugin: 'spring-boot'
group = 'installer'
version = '0.0.0'
bootRun {
main = 'org.springframework.boot.SpringApplication'
if (project.hasProperty('bootRunMain')) {
bootRun {
main = 'org.springframework.boot.SpringApplication'
}
}
if (project.hasProperty('nonJavaExecRun')) {
task run { }
}
jar {
baseName = 'installer'
}