diff --git a/src/main/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPlugin.groovy b/src/main/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPlugin.groovy index 5c412534..4bcc5903 100644 --- a/src/main/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPlugin.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPlugin.groovy @@ -75,6 +75,10 @@ class OspackageApplicationSpringBootPlugin implements Plugin { } } } + // Allow the springBoot extension configuration to propagate to the application plugin + if (!project.application.mainClass.isPresent()) { + project.application.mainClass.set(project.springBoot.mainClassName) + } } } else { project.tasks.getByName(DistributionPlugin.TASK_INSTALL_NAME).dependsOn('bootRepackage') diff --git a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy index dd45cacb..6e3927ca 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy @@ -122,6 +122,31 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { '2.4.2' | _ } + @Unroll + def 'application runs for boot #bootVersion when mainClassName configured using springBoot extension'() { + final applicationDir = "$moduleName-boot" + final startScript = file("build/install/$applicationDir/bin/$moduleName") + + buildFile << buildScript(bootVersion, startScript) + buildFile << """ + mainClassName = null + + springBoot { + mainClassName = 'nebula.test.HelloWorld' + } + """ + + when: + def result = runTasksSuccessfully('runStartScript') + + then: + result.standardOutput.contains('Hello Integration Test') + + where: + bootVersion | _ + '2.4.2' | _ + } + @Unroll def 'can customize destination for boot #bootVersion'() { buildFile << buildScript(bootVersion, null)