Configure assemble to depend upon bootJar or bootWar
Closes gh-8824
This commit is contained in:
@@ -173,4 +173,17 @@ public class PackagingDocumentationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootJarAndJar() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-and-jar.gradle")
|
||||
.build("assemble");
|
||||
File jar = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(jar).isFile();
|
||||
File bootJar = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + "-boot.jar");
|
||||
assertThat(bootJar).isFile();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -79,4 +83,23 @@ public class JavaPluginActionIntegrationTests {
|
||||
.contains("compileTestJava = UTF-8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assembleRunsBootJarAndJarIsSkipped() {
|
||||
BuildResult result = this.gradleBuild.build("assemble");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":jar").getOutcome()).isEqualTo(TaskOutcome.SKIPPED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jarAndBootJarCanBothBeBuilt() {
|
||||
BuildResult result = this.gradleBuild.build("assemble");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":jar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
assertThat(buildLibs.listFiles()).containsExactlyInAnyOrder(
|
||||
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"),
|
||||
new File(buildLibs,
|
||||
this.gradleBuild.getProjectDir().getName() + "-boot.jar"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -59,4 +63,23 @@ public class WarPluginActionIntegrationTests {
|
||||
.getOutput()).contains("bootWeb exists = true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assembleRunsBootWarAndWarIsSkipped() {
|
||||
BuildResult result = this.gradleBuild.build("assemble");
|
||||
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":war").getOutcome()).isEqualTo(TaskOutcome.SKIPPED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warAndBootWarCanBothBeBuilt() {
|
||||
BuildResult result = this.gradleBuild.build("assemble");
|
||||
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":war").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
assertThat(buildLibs.listFiles()).containsExactlyInAnyOrder(
|
||||
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"),
|
||||
new File(buildLibs,
|
||||
this.gradleBuild.getProjectDir().getName() + "-boot.war"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'java'
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'java'
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
classifier = 'boot'
|
||||
}
|
||||
|
||||
jar {
|
||||
enabled = true
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'war'
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'war'
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
classifier = 'boot'
|
||||
}
|
||||
|
||||
war {
|
||||
enabled = true
|
||||
}
|
||||
Reference in New Issue
Block a user