Merge branch '1.3.x'
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user