Skip to content

Commit

Permalink
Merge branch '1.3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jun 15, 2016
2 parents e4f9593 + c808de0 commit fc78a8d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ public void repackagingEnabledExcludeDevtools() throws IOException {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ dependencies {
}

springBoot {
mainClass = 'foo.bar.Baz'
if (!project.hasProperty("noMainClass")) {
mainClass = 'foo.bar.Baz'
}
excludeDevtools = Boolean.valueOf(project.excludeDevtools)
}

Expand All @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,13 @@ else if (this.extension.getMainClass() != null) {
.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() {
Expand All @@ -264,7 +269,10 @@ private String getMainClassNameProperty() {
}
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 {
Expand Down

0 comments on commit fc78a8d

Please sign in to comment.