mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Add nullability annotations to tests in build-plugin/spring-boot-gradle-plugin
See gh-47263
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.gradle.plugins.ide.eclipse.EclipsePlugin
|
||||
import org.gradle.plugins.ide.eclipse.model.Classpath
|
||||
import org.gradle.plugins.ide.eclipse.model.Library
|
||||
|
||||
@@ -163,3 +162,11 @@ plugins.withType(EclipsePlugin) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
tasks.named("compileDockerTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+92
-30
@@ -34,6 +34,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
@@ -67,6 +68,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@DisabledIfDockerUnavailable
|
||||
class BootBuildImageIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -75,7 +77,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("Running detector");
|
||||
assertThat(result.getOutput()).contains("Running builder");
|
||||
@@ -91,7 +95,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("Running creator");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
@@ -106,7 +112,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage", "-PapplyWarPlugin");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -122,7 +130,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -137,7 +147,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("example/test-image-name");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -149,7 +161,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("example/test-image-custom");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -164,7 +178,9 @@ class BootBuildImageIntegrationTests {
|
||||
"--imageName=example/test-image-cmd", "--builder=ghcr.io/spring-io/spring-boot-cnb-test-builder:0.0.2",
|
||||
"--trustBuilder", "--runImage=paketobuildpacks/run-noble-tiny", "--createdDate=2020-07-01T12:34:56Z",
|
||||
"--applicationDirectory=/application");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("example/test-image-cmd");
|
||||
assertThat(result.getOutput()).contains("Running creator");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
@@ -180,10 +196,14 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("Pulled builder image").contains("Pulled run image");
|
||||
result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("Pulled builder image").doesNotContain("Pulled run image");
|
||||
removeImages(projectName);
|
||||
}
|
||||
@@ -194,7 +214,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done");
|
||||
@@ -209,7 +231,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeBuildpackContent();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Hello World buildpack");
|
||||
removeImages(projectName);
|
||||
@@ -224,7 +248,9 @@ class BootBuildImageIntegrationTests {
|
||||
tarGzipBuildpackContent();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Hello World buildpack");
|
||||
removeImages(projectName);
|
||||
@@ -236,7 +262,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done");
|
||||
@@ -250,7 +278,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeCertificateBindingFiles();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("binding: certificates/type=ca-certificates");
|
||||
@@ -266,7 +296,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -280,7 +312,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -293,7 +327,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("Network status: curl failed");
|
||||
@@ -307,7 +343,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -323,7 +361,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -352,7 +392,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -367,7 +409,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -386,7 +430,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -399,7 +445,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
@@ -418,7 +466,9 @@ class BootBuildImageIntegrationTests {
|
||||
removeImages(builderImage, runImage, buildpackImage);
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput())
|
||||
.contains("Pulling builder image '" + builderImage + "' for platform 'linux/arm64'");
|
||||
@@ -446,7 +496,9 @@ class BootBuildImageIntegrationTests {
|
||||
removeImages(builderImage, runImage, buildpackImage);
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput())
|
||||
.contains("Pulling builder image '" + builderImage + "' for platform 'linux/arm64'");
|
||||
@@ -462,7 +514,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains("Error parsing 'invalid date' as an image created date");
|
||||
}
|
||||
|
||||
@@ -471,7 +525,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains("Forced builder failure");
|
||||
assertThat(result.getOutput()).containsPattern("Builder lifecycle '.*' failed with status code");
|
||||
}
|
||||
@@ -481,7 +537,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage", "--imageName=example/Invalid-Image-Name");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).containsPattern("must be an image reference")
|
||||
.containsPattern("example/Invalid-Image-Name");
|
||||
}
|
||||
@@ -491,7 +549,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains("'urn:cnb:builder:example/does-not-exist:0.0.1' not found in builder");
|
||||
}
|
||||
|
||||
@@ -500,7 +560,9 @@ class BootBuildImageIntegrationTests {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).containsPattern("must be an image reference")
|
||||
.containsPattern("example/Invalid-Tag-Name");
|
||||
}
|
||||
|
||||
+5
-1
@@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@@ -55,6 +56,7 @@ class BootBuildImageRegistryIntegrationTests {
|
||||
|
||||
String registryAddress;
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@BeforeEach
|
||||
@@ -69,7 +71,9 @@ class BootBuildImageRegistryIntegrationTests {
|
||||
String repoName = "test-image";
|
||||
String imageName = this.registryAddress + "/" + repoName;
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage", "--imageName=" + imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootBuildImage");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("Building image")
|
||||
.contains("Successfully built image")
|
||||
.contains("Pushing image '" + imageName + ":latest" + "'")
|
||||
|
||||
+20
-12
@@ -21,6 +21,7 @@ import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -39,12 +40,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility
|
||||
class BuildInfoDslIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
void basicJar() {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
|
||||
@@ -54,8 +57,9 @@ class BuildInfoDslIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void jarWithCustomName() {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", "foo");
|
||||
@@ -65,8 +69,9 @@ class BuildInfoDslIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void basicWar() {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
|
||||
@@ -76,8 +81,9 @@ class BuildInfoDslIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void warWithCustomName() {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", "foo");
|
||||
@@ -87,8 +93,9 @@ class BuildInfoDslIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void additionalProperties() {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
|
||||
@@ -100,8 +107,9 @@ class BuildInfoDslIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void classesDependency() {
|
||||
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
private Properties buildInfoProperties() {
|
||||
|
||||
+20
-12
@@ -33,6 +33,7 @@ import java.util.zip.ZipFile;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -50,6 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility
|
||||
class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -84,8 +86,9 @@ class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void zipDistributionForJarCanBeBuilt() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootDistZip").task(":bootDistZip");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.zip");
|
||||
assertThat(distribution).isFile();
|
||||
@@ -96,8 +99,9 @@ class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void tarDistributionForJarCanBeBuilt() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootDistTar").task(":bootDistTar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
@@ -108,8 +112,9 @@ class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void zipDistributionForWarCanBeBuilt() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootDistZip").task(":bootDistZip");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.zip");
|
||||
assertThat(distribution).isFile();
|
||||
@@ -120,8 +125,9 @@ class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void tarDistributionForWarCanBeBuilt() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootDistTar").task(":bootDistTar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
@@ -132,8 +138,9 @@ class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void applicationNameCanBeUsedToCustomizeDistributionName() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootDistTar").task(":bootDistTar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/custom-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
@@ -144,8 +151,9 @@ class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void scriptsHaveCorrectPermissions() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootDistTar").task(":bootDistTar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
|
||||
+10
-6
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -33,20 +34,23 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility
|
||||
class DependencyManagementPluginActionIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
void noDependencyManagementIsAppliedByDefault() {
|
||||
assertThat(this.gradleBuild.build("doesNotHaveDependencyManagement")
|
||||
.task(":doesNotHaveDependencyManagement")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("doesNotHaveDependencyManagement")
|
||||
.task(":doesNotHaveDependencyManagement");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bomIsImportedWhenDependencyManagementPluginIsApplied() {
|
||||
assertThat(this.gradleBuild.build("hasDependencyManagement", "-PapplyDependencyManagementPlugin")
|
||||
.task(":hasDependencyManagement")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("hasDependencyManagement", "-PapplyDependencyManagementPlugin")
|
||||
.task(":hasDependencyManagement");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
-5
@@ -28,6 +28,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -45,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility(configurationCache = true)
|
||||
class JavaPluginActionIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -105,8 +107,12 @@ class JavaPluginActionIntegrationTests {
|
||||
@TestTemplate
|
||||
void assembleRunsBootJarAndJar() {
|
||||
BuildResult result = this.gradleBuild.build("assemble");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":jar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask bootJar = result.task(":bootJar");
|
||||
assertThat(bootJar).isNotNull();
|
||||
assertThat(bootJar.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask jar = result.task(":jar");
|
||||
assertThat(jar).isNotNull();
|
||||
assertThat(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"),
|
||||
@@ -116,7 +122,9 @@ class JavaPluginActionIntegrationTests {
|
||||
@TestTemplate
|
||||
void errorMessageIsHelpfulWhenMainClassCannotBeResolved() {
|
||||
BuildResult result = this.gradleBuild.buildAndFail("build", "-PapplyJavaPlugin");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootJar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains("Main class name has not been configured and it could not be resolved");
|
||||
}
|
||||
|
||||
@@ -128,7 +136,9 @@ class JavaPluginActionIntegrationTests {
|
||||
new JarOutputStream(new FileOutputStream(new File(libs, "spring-boot-configuration-processor-1.2.3.jar")))
|
||||
.close();
|
||||
BuildResult result = this.gradleBuild.build("compileJava");
|
||||
assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":compileJava");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("compileJava compiler args: [-parameters, -Aorg.springframework.boot."
|
||||
+ "configurationprocessor.additionalMetadataLocations="
|
||||
+ new File(this.gradleBuild.getProjectDir(), "src/main/resources").getCanonicalPath());
|
||||
@@ -138,7 +148,9 @@ class JavaPluginActionIntegrationTests {
|
||||
void additionalMetadataLocationsNotConfiguredWhenProcessorIsAbsent() throws IOException {
|
||||
createMinimalMainSource();
|
||||
BuildResult result = this.gradleBuild.build("compileJava");
|
||||
assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":compileJava");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("compileJava compiler args: [-parameters]");
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -28,6 +28,7 @@ import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility(minimumVersion = "8.3")
|
||||
class NativeImagePluginActionIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -58,7 +60,9 @@ class NativeImagePluginActionIntegrationTests {
|
||||
void reachabilityMetadataConfigurationFilesAreCopiedToJar() throws IOException {
|
||||
writeDummySpringApplicationAotProcessorMainClass();
|
||||
BuildResult result = this.gradleBuild.build("bootJar");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootJar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
File jarFile = new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(buildLibs.listFiles()).contains(jarFile);
|
||||
@@ -76,7 +80,9 @@ class NativeImagePluginActionIntegrationTests {
|
||||
FileSystemUtils.copyRecursively(new File("src/test/resources/reachability-metadata-repository"),
|
||||
new File(this.gradleBuild.getProjectDir(), "reachability-metadata-repository"));
|
||||
BuildResult result = this.gradleBuild.build("bootJar");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootJar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
File jarFile = new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(buildLibs.listFiles()).contains(jarFile);
|
||||
@@ -122,7 +128,9 @@ class NativeImagePluginActionIntegrationTests {
|
||||
void nativeEntryIsAddedToManifest() throws IOException {
|
||||
writeDummySpringApplicationAotProcessorMainClass();
|
||||
BuildResult result = this.gradleBuild.build("bootJar");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootJar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
try (JarFile jarFile = new JarFile(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"))) {
|
||||
Manifest manifest = jarFile.getManifest();
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility
|
||||
class OnlyDependencyManagementIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
|
||||
+8
-4
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||
@@ -40,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
@GradleCompatibility
|
||||
class SpringBootAotPluginIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -126,14 +128,16 @@ class SpringBootAotPluginIntegrationTests {
|
||||
void processAotRunsWhenProjectHasMainSource() throws IOException {
|
||||
writeMainClass("org.springframework.boot", "SpringApplicationAotProcessor");
|
||||
writeMainClass("com.example", "Main");
|
||||
assertThat(this.gradleBuild.build("processAot").task(":processAot").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("processAot").task(":processAot");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void processTestAotIsSkippedWhenProjectHasNoTestSource() {
|
||||
assertThat(this.gradleBuild.build("processTestAot").task(":processTestAot").getOutcome())
|
||||
.isEqualTo(TaskOutcome.NO_SOURCE);
|
||||
BuildTask task = this.gradleBuild.build("processTestAot").task(":processTestAot");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.NO_SOURCE);
|
||||
}
|
||||
|
||||
// gh-37343
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class SpringBootPluginTests {
|
||||
|
||||
@TempDir
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
File temp;
|
||||
|
||||
@Test
|
||||
|
||||
+11
-3
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -43,6 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility
|
||||
class WarPluginActionIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -60,8 +62,12 @@ class WarPluginActionIntegrationTests {
|
||||
@TestTemplate
|
||||
void assembleRunsBootWarAndWar() {
|
||||
BuildResult result = this.gradleBuild.build("assemble");
|
||||
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":war").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask bootWar = result.task(":bootWar");
|
||||
assertThat(bootWar).isNotNull();
|
||||
assertThat(bootWar.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask war = result.task(":war");
|
||||
assertThat(war).isNotNull();
|
||||
assertThat(war.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
List<File> expected = new ArrayList<>();
|
||||
expected.add(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"));
|
||||
@@ -75,7 +81,9 @@ class WarPluginActionIntegrationTests {
|
||||
@TestTemplate
|
||||
void errorMessageIsHelpfulWhenMainClassCannotBeResolved() {
|
||||
BuildResult result = this.gradleBuild.buildAndFail("build", "-PapplyWarPlugin");
|
||||
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootWar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains("Main class name has not been configured and it could not be resolved");
|
||||
}
|
||||
|
||||
|
||||
+42
-22
@@ -25,6 +25,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.time.Instant;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -43,11 +44,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility(configurationCache = true)
|
||||
class BuildInfoIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
void defaultValues() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties buildInfoProperties = buildInfoProperties();
|
||||
assertThat(buildInfoProperties).containsKey("build.time");
|
||||
assertThat(buildInfoProperties).doesNotContainKey("build.artifact");
|
||||
@@ -58,7 +62,9 @@ class BuildInfoIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void basicExecution() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties buildInfoProperties = buildInfoProperties();
|
||||
assertThat(buildInfoProperties).containsKey("build.time");
|
||||
assertThat(buildInfoProperties).containsEntry("build.artifact", "foo");
|
||||
@@ -70,11 +76,15 @@ class BuildInfoIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenExecutedTwiceAsTimeChanges() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties first = buildInfoProperties();
|
||||
String firstBuildTime = first.getProperty("build.time");
|
||||
assertThat(firstBuildTime).isNotNull();
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties second = buildInfoProperties();
|
||||
String secondBuildTime = second.getProperty("build.time");
|
||||
assertThat(secondBuildTime).isNotNull();
|
||||
@@ -83,22 +93,24 @@ class BuildInfoIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void upToDateWhenExecutedTwiceWithFixedTime() {
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() {
|
||||
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.1.0")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("projectVersion", "0.1.0")
|
||||
.build("buildInfo")
|
||||
.task(":buildInfo")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.2.0")
|
||||
.build("buildInfo")
|
||||
.task(":buildInfo")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
.task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("projectVersion", "0.2.0").build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@@ -106,29 +118,37 @@ class BuildInfoIntegrationTests {
|
||||
Path gradleProperties = new File(this.gradleBuild.getProjectDir(), "gradle.properties").toPath();
|
||||
Files.writeString(gradleProperties, "version=0.1.0", StandardOpenOption.CREATE, StandardOpenOption.WRITE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Files.writeString(gradleProperties, "version=0.2.0", StandardOpenOption.CREATE, StandardOpenOption.WRITE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void reproducibleOutputWithFixedTime() throws IOException, InterruptedException {
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File buildInfoProperties = new File(this.gradleBuild.getProjectDir(), "build/buildInfo/build-info.properties");
|
||||
String firstHash = FileUtils.sha1Hash(buildInfoProperties);
|
||||
assertThat(buildInfoProperties.delete()).isTrue();
|
||||
Thread.sleep(1500);
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String secondHash = FileUtils.sha1Hash(buildInfoProperties);
|
||||
assertThat(firstHash).isEqualTo(secondHash);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void excludeProperties() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("buildInfo").task(":buildInfo");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties buildInfoProperties = buildInfoProperties();
|
||||
assertThat(buildInfoProperties).doesNotContainKey("build.group");
|
||||
assertThat(buildInfoProperties).doesNotContainKey("build.artifact");
|
||||
|
||||
+2
@@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatException;
|
||||
class BuildInfoTests {
|
||||
|
||||
@TempDir
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
File temp;
|
||||
|
||||
@Test
|
||||
@@ -163,6 +164,7 @@ class BuildInfoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("NullAway") // Test null check
|
||||
void nullAdditionalPropertyProducesInformativeFailure() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
assertThatException().isThrownBy(() -> task.getProperties().getAdditional().put("a", null))
|
||||
|
||||
+155
-95
@@ -49,6 +49,7 @@ import org.apache.commons.compress.archivers.zip.UnixStat;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -79,6 +80,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
private final String indexPath;
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
protected AbstractBootArchiveIntegrationTests(String taskName, String libPath, String classesPath,
|
||||
@@ -91,81 +93,91 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void basicBuild() {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void reproducibleArchive() throws IOException, InterruptedException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
|
||||
String firstHash = FileUtils.sha1Hash(jar);
|
||||
Thread.sleep(1500);
|
||||
assertThat(this.gradleBuild.build("clean", this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build("clean", this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String secondHash = FileUtils.sha1Hash(jar);
|
||||
assertThat(firstHash).isEqualTo(secondHash);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void upToDateWhenBuiltTwice() {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void upToDateWhenBuiltTwiceWithLaunchScriptIncluded() {
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
BuildTask task = this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenLaunchScriptWasNotIncludedAndThenIsIncluded() {
|
||||
assertThat(this.gradleBuild.scriptProperty("launchScript", "")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("launchScript", "")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("launchScript", "launchScript()")
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("launchScript", "launchScript()")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenLaunchScriptWasIncludedAndThenIsNotIncluded() {
|
||||
assertThat(this.gradleBuild.scriptProperty("launchScript", "launchScript()")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("launchScript", "launchScript()")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("launchScript", "")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("launchScript", "").build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenLaunchScriptPropertyChanges() {
|
||||
assertThat(this.gradleBuild.scriptProperty("launchScriptProperty", "alpha")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("launchScriptProperty", "alpha")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("launchScriptProperty", "bravo")
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("launchScriptProperty", "bravo")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void applicationPluginMainClassNameIsUsed() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.CustomMain");
|
||||
@@ -174,8 +186,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void springBootExtensionMainClassNameIsUsed() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.CustomMain");
|
||||
@@ -184,8 +197,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void duplicatesAreHandledGracefully() {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@@ -193,8 +207,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
File srcMainResources = new File(this.gradleBuild.getProjectDir(), "src/main/resources");
|
||||
srcMainResources.mkdirs();
|
||||
new File(srcMainResources, "resource").createNewFile();
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -211,8 +226,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void developmentOnlyDependenciesCanBeIncludedInTheArchive() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -226,8 +242,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
@TestTemplate
|
||||
void versionMismatchBetweenTransitiveDevelopmentOnlyImplementationDependenciesDoesNotRemoveDependencyFromTheArchive()
|
||||
throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -243,8 +260,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
File srcMainResources = new File(this.gradleBuild.getProjectDir(), "src/main/resources");
|
||||
srcMainResources.mkdirs();
|
||||
new File(srcMainResources, "resource").createNewFile();
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -261,8 +279,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void testAndDevelopmentOnlyDependenciesCanBeIncludedInTheArchive() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -279,8 +298,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
createDependenciesStarterJar(new File(flatDirRepository, "starter.jar"));
|
||||
createDependenciesDeveloperToolsJar(new File(flatDirRepository, "devonly.jar"));
|
||||
createStandardJar(new File(flatDirRepository, "standard.jar"));
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -293,65 +313,75 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
@TestTemplate
|
||||
void startClassIsSetByResolvingTheMainClass() throws IOException {
|
||||
copyMainClassApplication();
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Attributes mainAttributes = jarFile.getManifest().getMainAttributes();
|
||||
assertThat(mainAttributes.getValue("Start-Class"))
|
||||
.isEqualTo("com.example." + this.taskName.toLowerCase(Locale.ENGLISH) + ".main.CustomMainClass");
|
||||
}
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void upToDateWhenBuiltWithDefaultLayeredAndThenWithExplicitLayered() {
|
||||
assertThat(this.gradleBuild.scriptProperty("layered", "")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("layered", "")
|
||||
.build("" + this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("layered", "layered {}")
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("layered", "layered {}")
|
||||
.build("" + this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenBuiltWithoutLayersAndThenWithLayers() {
|
||||
assertThat(this.gradleBuild.scriptProperty("layerEnablement", "enabled = false")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("layerEnablement", "enabled = false")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("layerEnablement", "enabled = true")
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("layerEnablement", "enabled = true")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void notUpToDateWhenBuiltWithToolsAndThenWithoutTools() {
|
||||
assertThat(this.gradleBuild.scriptProperty("includeTools", "")
|
||||
BuildTask task = this.gradleBuild.scriptProperty("includeTools", "")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.scriptProperty("includeTools", "includeTools = false")
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = this.gradleBuild.scriptProperty("includeTools", "includeTools = false")
|
||||
.build(this.taskName)
|
||||
.task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void layersWithCustomSourceSet() {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void implicitLayers() throws IOException {
|
||||
writeMainClass();
|
||||
writeResource();
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Map<String, List<String>> indexedLayers;
|
||||
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
@@ -387,11 +417,15 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
assertThat(indexedLayers.get("application"))
|
||||
.containsExactly(getExpectedApplicationLayerContents(this.classesPath));
|
||||
BuildResult listLayers = this.gradleBuild.build("listLayers");
|
||||
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = listLayers.task(":listLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String listLayersOutput = listLayers.getOutput();
|
||||
assertThat(new BufferedReader(new StringReader(listLayersOutput)).lines()).containsSequence(layerNames);
|
||||
BuildResult extractLayers = this.gradleBuild.build("extractLayers");
|
||||
assertThat(extractLayers.task(":extractLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = extractLayers.task(":extractLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertExtractedLayers(layerNames, indexedLayers);
|
||||
}
|
||||
|
||||
@@ -402,8 +436,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
writeSettingsGradle();
|
||||
writeMainClass();
|
||||
writeResource();
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build(this.taskName).task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Map<String, List<String>> indexedLayers;
|
||||
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
@@ -436,11 +471,15 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
.containsExactly(getExpectedApplicationLayerContents(this.classesPath, this.libPath + "alpha-1.2.3.jar",
|
||||
this.libPath + "bravo-1.2.3.jar", this.libPath + "charlie-1.2.3.jar"));
|
||||
BuildResult listLayers = this.gradleBuild.build("listLayers");
|
||||
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = listLayers.task(":listLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String listLayersOutput = listLayers.getOutput();
|
||||
assertThat(new BufferedReader(new StringReader(listLayersOutput)).lines()).containsSequence(layerNames);
|
||||
BuildResult extractLayers = this.gradleBuild.build("extractLayers");
|
||||
assertThat(extractLayers.task(":extractLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = extractLayers.task(":extractLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertExtractedLayers(layerNames, indexedLayers);
|
||||
}
|
||||
|
||||
@@ -449,7 +488,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
writeMainClass();
|
||||
writeResource();
|
||||
BuildResult build = this.gradleBuild.build(this.taskName);
|
||||
assertThat(build.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = build.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Map<String, List<String>> indexedLayers;
|
||||
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
@@ -482,11 +523,15 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
appLayer.removeAll(Arrays.asList(appLayerContents));
|
||||
assertThat(appLayer).containsExactly("org/");
|
||||
BuildResult listLayers = this.gradleBuild.build("listLayers");
|
||||
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = listLayers.task(":listLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String listLayersOutput = listLayers.getOutput();
|
||||
assertThat(new BufferedReader(new StringReader(listLayersOutput)).lines()).containsSequence(layerNames);
|
||||
BuildResult extractLayers = this.gradleBuild.build("extractLayers");
|
||||
assertThat(extractLayers.task(":extractLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = extractLayers.task(":extractLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertExtractedLayers(layerNames, indexedLayers);
|
||||
}
|
||||
|
||||
@@ -496,7 +541,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
writeMainClass();
|
||||
writeResource();
|
||||
BuildResult build = this.gradleBuild.build(this.taskName);
|
||||
assertThat(build.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = build.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Map<String, List<String>> indexedLayers;
|
||||
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
@@ -538,11 +585,15 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
appLayer.removeAll(Arrays.asList(appLayerContents));
|
||||
assertThat(appLayer).containsExactly("org/");
|
||||
BuildResult listLayers = this.gradleBuild.build("listLayers");
|
||||
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = listLayers.task(":listLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String listLayersOutput = listLayers.getOutput();
|
||||
assertThat(new BufferedReader(new StringReader(listLayersOutput)).lines()).containsSequence(layerNames);
|
||||
BuildResult extractLayers = this.gradleBuild.build("extractLayers");
|
||||
assertThat(extractLayers.task(":extractLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
task = extractLayers.task(":extractLayers");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertExtractedLayers(layerNames, indexedLayers);
|
||||
}
|
||||
|
||||
@@ -561,7 +612,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
BuildResult build = this.gradleBuild.build(this.taskName);
|
||||
assertThat(build.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = build.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> classesEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
@@ -575,7 +628,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
@TestTemplate
|
||||
void javaVersionIsSetInManifest() throws IOException {
|
||||
BuildResult result = this.gradleBuild.build(this.taskName);
|
||||
assertThat(result.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Build-Jdk-Spec")).isNotEmpty();
|
||||
}
|
||||
@@ -584,7 +639,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
@TestTemplate
|
||||
void defaultDirAndFileModesAreUsed() throws IOException {
|
||||
BuildResult result = this.gradleBuild.build(this.taskName);
|
||||
assertThat(result.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (ZipFile jarFile = ZipFile.builder()
|
||||
.setFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])
|
||||
.get()) {
|
||||
@@ -612,7 +669,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
"The CopyProcessingSpec.setFileMode(Integer) method has been deprecated",
|
||||
"upgrading_version_8.html#unix_file_permissions_deprecated")
|
||||
.build(this.taskName);
|
||||
assertThat(result.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":" + this.taskName);
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (ZipFile jarFile = ZipFile.builder()
|
||||
.setFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])
|
||||
.get()) {
|
||||
@@ -757,6 +816,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
assertThat(extractedLayers.keySet()).isEqualTo(indexedLayers.keySet());
|
||||
extractedLayers.forEach((name, contents) -> {
|
||||
List<String> index = indexedLayers.get(name);
|
||||
assertThat(index).isNotNull();
|
||||
List<String> unexpected = new ArrayList<>();
|
||||
for (String file : contents) {
|
||||
if (!isInIndex(index, file)) {
|
||||
|
||||
+1
@@ -87,6 +87,7 @@ import static org.mockito.Mockito.mock;
|
||||
abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
|
||||
@TempDir
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
File temp;
|
||||
|
||||
private final Class<T> taskClass;
|
||||
|
||||
+3
-1
@@ -201,7 +201,9 @@ class BootBuildImageTests {
|
||||
@Test
|
||||
void whenRunImageIsConfiguredThenRequestUsesSpecifiedRunImage() {
|
||||
this.buildImage.getRunImage().set("example.com/test/run:1.0");
|
||||
assertThat(this.buildImage.createRequest().getRunImage().getName()).isEqualTo("test/run");
|
||||
ImageReference runImage = this.buildImage.createRequest().getRunImage();
|
||||
assertThat(runImage).isNotNull();
|
||||
assertThat(runImage.getName()).isEqualTo("test/run");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-1
@@ -24,6 +24,7 @@ import java.util.TreeSet;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -48,7 +49,9 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void signed() throws Exception {
|
||||
assertThat(this.gradleBuild.build("bootJar").task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = this.gradleBuild.build("bootJar").task(":bootJar");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
|
||||
try (JarFile jarFile = new JarFile(jar)) {
|
||||
assertThat(jarFile.getEntry("META-INF/BOOT.SF")).isNotNull();
|
||||
|
||||
+63
-24
@@ -20,12 +20,14 @@ import java.io.File;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.gradle.api.GradleException;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import org.springframework.boot.buildpack.platform.build.BuilderDockerConfiguration;
|
||||
import org.springframework.boot.buildpack.platform.docker.configuration.DockerConnectionConfiguration;
|
||||
import org.springframework.boot.buildpack.platform.docker.configuration.DockerRegistryAuthentication;
|
||||
import org.springframework.boot.gradle.junit.GradleProjectBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -54,9 +56,14 @@ class DockerSpecTests {
|
||||
void asDockerConfigurationWithDefaults() {
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
assertThat(dockerConfiguration.connection()).isNull();
|
||||
assertThat(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"")
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(builderRegistryAuthentication.getAuthHeader()).isNull();
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
@@ -69,13 +76,19 @@ class DockerSpecTests {
|
||||
this.dockerSpec.getCertPath().set("/tmp/ca-cert");
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
DockerConnectionConfiguration.Host host = (DockerConnectionConfiguration.Host) dockerConfiguration.connection();
|
||||
assertThat(host).isNotNull();
|
||||
assertThat(host.address()).isEqualTo("docker.example.com");
|
||||
assertThat(host.secure()).isTrue();
|
||||
assertThat(host.certificatePath()).isEqualTo("/tmp/ca-cert");
|
||||
assertThat(dockerConfiguration.bindHostToBuilder()).isFalse();
|
||||
assertThat(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"")
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(builderRegistryAuthentication.getAuthHeader()).isNull();
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
@@ -86,13 +99,19 @@ class DockerSpecTests {
|
||||
this.dockerSpec.getHost().set("docker.example.com");
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
DockerConnectionConfiguration.Host host = (DockerConnectionConfiguration.Host) dockerConfiguration.connection();
|
||||
assertThat(host).isNotNull();
|
||||
assertThat(host.address()).isEqualTo("docker.example.com");
|
||||
assertThat(host.secure()).isFalse();
|
||||
assertThat(host.certificatePath()).isNull();
|
||||
assertThat(dockerConfiguration.bindHostToBuilder()).isFalse();
|
||||
assertThat(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"")
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(builderRegistryAuthentication.getAuthHeader()).isNull();
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
@@ -104,11 +123,17 @@ class DockerSpecTests {
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
DockerConnectionConfiguration.Context host = (DockerConnectionConfiguration.Context) dockerConfiguration
|
||||
.connection();
|
||||
assertThat(host).isNotNull();
|
||||
assertThat(host.context()).isEqualTo("test-context");
|
||||
assertThat(dockerConfiguration.bindHostToBuilder()).isFalse();
|
||||
assertThat(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"")
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(builderRegistryAuthentication.getAuthHeader()).isNull();
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
@@ -128,13 +153,19 @@ class DockerSpecTests {
|
||||
this.dockerSpec.getBindHostToBuilder().set(true);
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
DockerConnectionConfiguration.Host host = (DockerConnectionConfiguration.Host) dockerConfiguration.connection();
|
||||
assertThat(host).isNotNull();
|
||||
assertThat(host.address()).isEqualTo("docker.example.com");
|
||||
assertThat(host.secure()).isFalse();
|
||||
assertThat(host.certificatePath()).isNull();
|
||||
assertThat(dockerConfiguration.bindHostToBuilder()).isTrue();
|
||||
assertThat(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"")
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(builderRegistryAuthentication.getAuthHeader()).isNull();
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
@@ -155,13 +186,17 @@ class DockerSpecTests {
|
||||
registry.getEmail().set("docker2@example.com");
|
||||
});
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
assertThat(decoded(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"user1\"")
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(builderRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"user1\"")
|
||||
.contains("\"password\" : \"secret1\"")
|
||||
.contains("\"email\" : \"docker1@example.com\"")
|
||||
.contains("\"serveraddress\" : \"https://docker1.example.com\"");
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"user2\"")
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"username\" : \"user2\"")
|
||||
.contains("\"password\" : \"secret2\"")
|
||||
.contains("\"email\" : \"docker2@example.com\"")
|
||||
.contains("\"serveraddress\" : \"https://docker2.example.com\"");
|
||||
@@ -195,10 +230,14 @@ class DockerSpecTests {
|
||||
this.dockerSpec.builderRegistry((registry) -> registry.getToken().set("token1"));
|
||||
this.dockerSpec.publishRegistry((registry) -> registry.getToken().set("token2"));
|
||||
BuilderDockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
|
||||
assertThat(decoded(dockerConfiguration.builderRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"identitytoken\" : \"token1\"");
|
||||
assertThat(decoded(dockerConfiguration.publishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"identitytoken\" : \"token2\"");
|
||||
DockerRegistryAuthentication builderRegistryAuthentication = dockerConfiguration
|
||||
.builderRegistryAuthentication();
|
||||
assertThat(builderRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(builderRegistryAuthentication.getAuthHeader())).contains("\"identitytoken\" : \"token1\"");
|
||||
DockerRegistryAuthentication publishRegistryAuthentication = dockerConfiguration
|
||||
.publishRegistryAuthentication();
|
||||
assertThat(publishRegistryAuthentication).isNotNull();
|
||||
assertThat(decoded(publishRegistryAuthentication.getAuthHeader())).contains("\"identitytoken\" : \"token2\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,7 +251,7 @@ class DockerSpecTests {
|
||||
.withMessageContaining("Invalid Docker builder registry configuration");
|
||||
}
|
||||
|
||||
String decoded(String value) {
|
||||
@Nullable String decoded(@Nullable String value) {
|
||||
return (value != null) ? new String(Base64.getDecoder().decode(value)) : value;
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -19,6 +19,7 @@ package org.springframework.boot.gradle.tasks.bundling;
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
|
||||
@@ -36,12 +37,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility
|
||||
class MavenPublishingIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
void bootJarCanBePublished() {
|
||||
BuildResult result = this.gradleBuild.build("publish");
|
||||
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":publish");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(artifactWithSuffix("jar")).isFile();
|
||||
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName())
|
||||
@@ -53,7 +57,9 @@ class MavenPublishingIntegrationTests {
|
||||
@TestTemplate
|
||||
void bootWarCanBePublished() {
|
||||
BuildResult result = this.gradleBuild.build("publish");
|
||||
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":publish");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(artifactWithSuffix("war")).isFile();
|
||||
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName())
|
||||
|
||||
+38
-12
@@ -26,6 +26,7 @@ import java.util.jar.Manifest;
|
||||
|
||||
import org.assertj.core.api.Assumptions;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -44,6 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility(configurationCache = true)
|
||||
class BootRunIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@@ -51,7 +53,9 @@ class BootRunIntegrationTests {
|
||||
copyClasspathApplication();
|
||||
new File(this.gradleBuild.getProjectDir(), "src/main/resources").mkdirs();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput()).contains("2. " + canonicalPathOf("build/resources/main"));
|
||||
assertThat(result.getOutput()).doesNotContain(canonicalPathOf("src/main/resources"));
|
||||
@@ -61,7 +65,9 @@ class BootRunIntegrationTests {
|
||||
void sourceResourcesCanBeUsed() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. " + canonicalPathOf("src/main/resources"));
|
||||
assertThat(result.getOutput()).contains("2. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput()).doesNotContain(canonicalPathOf("build/resources/main"));
|
||||
@@ -71,7 +77,9 @@ class BootRunIntegrationTests {
|
||||
void springBootExtensionMainClassNameIsUsed() throws IOException {
|
||||
copyMainClassApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("com.example.bootrun.main.CustomMainClass");
|
||||
}
|
||||
|
||||
@@ -79,7 +87,9 @@ class BootRunIntegrationTests {
|
||||
void applicationPluginMainClassNameIsUsed() throws IOException {
|
||||
copyMainClassApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("com.example.bootrun.main.CustomMainClass");
|
||||
}
|
||||
|
||||
@@ -87,7 +97,9 @@ class BootRunIntegrationTests {
|
||||
void applicationPluginMainClassNameIsNotUsedWhenItIsNull() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput())
|
||||
.contains("Main class name = com.example.bootrun.classpath.BootRunClasspathApplication");
|
||||
}
|
||||
@@ -96,7 +108,9 @@ class BootRunIntegrationTests {
|
||||
void defaultJvmArgs() throws IOException {
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1");
|
||||
}
|
||||
|
||||
@@ -104,7 +118,9 @@ class BootRunIntegrationTests {
|
||||
void optimizedLaunchDisabledJvmArgs() throws IOException {
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("-Xverify:none").doesNotContain("-XX:TieredStopAtLevel=1");
|
||||
}
|
||||
|
||||
@@ -119,7 +135,9 @@ class BootRunIntegrationTests {
|
||||
}
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("-Dcom.bar=baz")
|
||||
.contains("-Dcom.foo=bar")
|
||||
.contains("-XX:TieredStopAtLevel=1");
|
||||
@@ -132,7 +150,9 @@ class BootRunIntegrationTests {
|
||||
createDependenciesStarterJar(new File(flatDirRepository, "starter.jar"));
|
||||
createStandardJar(new File(flatDirRepository, "standard.jar"));
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("standard.jar").doesNotContain("starter.jar");
|
||||
}
|
||||
|
||||
@@ -142,7 +162,9 @@ class BootRunIntegrationTests {
|
||||
output.mkdirs();
|
||||
FileSystemUtils.copyRecursively(new File("src/test/java/com/example/bootrun/main"), output);
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("com.example.bootrun.main.CustomMainClass");
|
||||
}
|
||||
|
||||
@@ -150,7 +172,9 @@ class BootRunIntegrationTests {
|
||||
void developmentOnlyDependenciesAreOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@@ -158,7 +182,9 @@ class BootRunIntegrationTests {
|
||||
void testAndDevelopmentOnlyDependenciesAreOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
|
||||
+26
-8
@@ -26,6 +26,7 @@ import java.util.jar.Manifest;
|
||||
|
||||
import org.assertj.core.api.Assumptions;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.BuildTask;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -44,13 +45,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@GradleCompatibility(configurationCache = true)
|
||||
class BootTestRunIntegrationTests {
|
||||
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
void basicExecution() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. " + canonicalPathOf("build/classes/java/test"))
|
||||
.contains("2. " + canonicalPathOf("build/resources/test"))
|
||||
.contains("3. " + canonicalPathOf("build/classes/java/main"))
|
||||
@@ -61,7 +65,9 @@ class BootTestRunIntegrationTests {
|
||||
void defaultJvmArgs() throws IOException {
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1");
|
||||
}
|
||||
|
||||
@@ -69,7 +75,9 @@ class BootTestRunIntegrationTests {
|
||||
void optimizedLaunchDisabledJvmArgs() throws IOException {
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("-Xverify:none").doesNotContain("-XX:TieredStopAtLevel=1");
|
||||
}
|
||||
|
||||
@@ -84,7 +92,9 @@ class BootTestRunIntegrationTests {
|
||||
}
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("-Dcom.bar=baz")
|
||||
.contains("-Dcom.foo=bar")
|
||||
.contains("-XX:TieredStopAtLevel=1");
|
||||
@@ -97,7 +107,9 @@ class BootTestRunIntegrationTests {
|
||||
createDependenciesStarterJar(new File(flatDirRepository, "starter.jar"));
|
||||
createStandardJar(new File(flatDirRepository, "standard.jar"));
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("standard.jar").doesNotContain("starter.jar");
|
||||
}
|
||||
|
||||
@@ -105,7 +117,9 @@ class BootTestRunIntegrationTests {
|
||||
void failsGracefullyWhenNoTestMainMethodIsFound() throws IOException {
|
||||
copyApplication("nomain");
|
||||
BuildResult result = this.gradleBuild.buildAndFail("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
if (this.gradleBuild.isConfigurationCache() && this.gradleBuild.gradleVersionIsAtLeast("8.0")) {
|
||||
assertThat(result.getOutput())
|
||||
.contains("Main class name has not been configured and it could not be resolved from classpath");
|
||||
@@ -121,7 +135,9 @@ class BootTestRunIntegrationTests {
|
||||
void developmentOnlyDependenciesAreNotOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@@ -129,7 +145,9 @@ class BootTestRunIntegrationTests {
|
||||
void testAndDevelopmentOnlyDependenciesAreOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildTask task = result.task(":bootTestRun");
|
||||
assertThat(task).isNotNull();
|
||||
assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user