Merge branch '1.3.x'

This commit is contained in:
Andy Wilkinson 2016-06-15 20:22:56 +01:00
commit fc78a8de90
3 changed files with 30 additions and 4 deletions

View File

@ -163,6 +163,17 @@ public class RepackagingTests {
assertThat(isDevToolsJarIncluded(repackageFile)).isFalse();
}
@Test
public void customRepackagingTaskWithOwnMainClassNameAnNoGlobalMainClassName() {
project.newBuild().forTasks("clean", "customRepackagedJarWithOwnMainClass")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PexcludeDevtools=false", "-PnoMainClass=true")
.run();
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "custom.jar").exists()).isTrue();
assertThat(new File(buildLibs, "custom.jar.original").exists()).isTrue();
}
private boolean isDevToolsJarIncluded(File repackageFile) throws IOException {
JarFile jarFile = new JarFile(repackageFile);
try {

View File

@ -23,7 +23,9 @@ dependencies {
}
springBoot {
mainClass = 'foo.bar.Baz'
if (!project.hasProperty("noMainClass")) {
mainClass = 'foo.bar.Baz'
}
excludeDevtools = Boolean.valueOf(project.excludeDevtools)
}
@ -50,3 +52,8 @@ task customRepackagedJar(type: BootRepackage, dependsOn: customJar) {
task customRepackagedJarWithStringReference(type: BootRepackage, dependsOn: customJar) {
withJarTask = 'customJar'
}
task customRepackagedJarWithOwnMainClass(type: BootRepackage, dependsOn: customJar) {
withJarTask = customJar
mainClass = 'foo.bar.Baz'
}

View File

@ -254,8 +254,13 @@ public class RepackageTask extends DefaultTask {
.property("main");
}
}
getLogger().info("Setting mainClass: " + mainClassName);
repackager.setMainClass(mainClassName);
if (mainClassName != null) {
getLogger().info("Setting mainClass: " + mainClassName);
repackager.setMainClass(mainClassName);
}
else {
getLogger().info("No mainClass configured");
}
}
private String getMainClassNameProperty() {
@ -264,7 +269,10 @@ public class RepackageTask extends DefaultTask {
}
ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
.getExtensions().getByName("ext");
return (String) extraProperties.get("mainClassName");
if (extraProperties.has("mainClassName")) {
return (String) extraProperties.get("mainClassName");
}
return null;
}
private LaunchScript getLaunchScript() throws IOException {