Leave jar and war tasks enabled but configured with a classifier

Closes gh-23797
This commit is contained in:
Andy Wilkinson
2021-03-16 10:25:16 +00:00
parent 3f2a069e71
commit ebdb046ca9
15 changed files with 99 additions and 89 deletions

View File

@@ -171,14 +171,34 @@ class PackagingDocumentationTests {
}
@TestTemplate
void bootJarAndJar() {
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-and-jar").build("assemble");
File jar = new File(this.gradleBuild.getProjectDir(),
void onlyBootJar() throws IOException {
this.gradleBuild.script("src/docs/gradle/packaging/only-boot-jar").build("assemble");
File plainJar = new File(this.gradleBuild.getProjectDir(),
"build/libs/" + this.gradleBuild.getProjectDir().getName() + "-plain.jar");
assertThat(plainJar).doesNotExist();
File bootJar = new File(this.gradleBuild.getProjectDir(),
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
assertThat(jar).isFile();
assertThat(bootJar).isFile();
try (JarFile jar = new JarFile(bootJar)) {
assertThat(jar.getEntry("BOOT-INF/")).isNotNull();
}
}
@TestTemplate
void classifiedBootJar() throws IOException {
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-and-jar-classifiers").build("assemble");
File plainJar = new File(this.gradleBuild.getProjectDir(),
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
assertThat(plainJar).isFile();
try (JarFile jar = new JarFile(plainJar)) {
assertThat(jar.getEntry("BOOT-INF/")).isNull();
}
File bootJar = new File(this.gradleBuild.getProjectDir(),
"build/libs/" + this.gradleBuild.getProjectDir().getName() + "-boot.jar");
assertThat(bootJar).isFile();
try (JarFile jar = new JarFile(bootJar)) {
assertThat(jar.getEntry("BOOT-INF/")).isNotNull();
}
}
@TestTemplate

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,10 +92,14 @@ class JavaPluginActionIntegrationTests {
}
@TestTemplate
void assembleRunsBootJarAndJarIsSkipped() {
void assembleRunsBootJarAndJar() {
BuildResult result = this.gradleBuild.build("assemble");
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.task(":jar").getOutcome()).isEqualTo(TaskOutcome.SKIPPED);
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() + "-plain.jar"));
}
@TestTemplate
@@ -105,17 +109,6 @@ class JavaPluginActionIntegrationTests {
assertThat(result.getOutput()).contains("Main class name has not been configured and it could not be resolved");
}
@TestTemplate
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"));
}
@TestTemplate
void additionalMetadataLocationsConfiguredWhenProcessorIsPresent() throws IOException {
createMinimalMainSource();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,21 +50,14 @@ class WarPluginActionIntegrationTests {
}
@TestTemplate
void assembleRunsBootWarAndWarIsSkipped() {
BuildResult result = this.gradleBuild.build("assemble");
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.task(":war").getOutcome()).isEqualTo(TaskOutcome.SKIPPED);
}
@TestTemplate
void warAndBootWarCanBothBeBuilt() {
void assembleRunsBootWarAndWar() {
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"));
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-plain.war"));
}
@TestTemplate