Test Gradle plugin against 9.0.0-milestone-9

This commit is contained in:
Andy Wilkinson 2025-04-15 10:58:38 +01:00
parent ec9fd892df
commit 25b72d66fc
5 changed files with 24 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,9 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.BuildResult;
@ -61,9 +63,13 @@ class WarPluginActionIntegrationTests {
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.task(":war").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); assertThat(result.task(":war").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs"); File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
assertThat(buildLibs.listFiles()).containsExactlyInAnyOrder( List<File> expected = new ArrayList<>();
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"), expected.add(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"));
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-plain.war")); expected.add(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-plain.war"));
if (this.gradleBuild.gradleVersionIsAtLeast("9.0-milestone-2")) {
expected.add(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-plain.jar"));
}
assertThat(buildLibs.listFiles()).containsExactlyInAnyOrderElementsOf(expected);
} }
@TestTemplate @TestTemplate

View File

@ -50,6 +50,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile; import org.apache.commons.compress.archivers.zip.ZipFile;
import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome; import org.gradle.testkit.runner.TaskOutcome;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.springframework.boot.loader.tools.FileUtils; import org.springframework.boot.loader.tools.FileUtils;
@ -597,6 +598,7 @@ abstract class AbstractBootArchiveIntegrationTests {
@TestTemplate @TestTemplate
void dirModeAndFileModeAreApplied() throws IOException { void dirModeAndFileModeAreApplied() throws IOException {
Assumptions.assumeTrue(this.gradleBuild.gradleVersionIsLessThan("9.0-milestone-1"));
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.8-rc-1") BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.8-rc-1")
.expectDeprecationMessages("The CopyProcessingSpec.setDirMode(Integer) method has been deprecated", .expectDeprecationMessages("The CopyProcessingSpec.setDirMode(Integer) method has been deprecated",
"The CopyProcessingSpec.setFileMode(Integer) method has been deprecated", "The CopyProcessingSpec.setFileMode(Integer) method has been deprecated",

View File

@ -25,6 +25,7 @@ import java.util.jar.JarFile;
import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome; import org.gradle.testkit.runner.TaskOutcome;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.springframework.boot.gradle.junit.GradleCompatibility; import org.springframework.boot.gradle.junit.GradleCompatibility;
@ -56,6 +57,7 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
@TestTemplate @TestTemplate
void whenAResolvableCopyOfAnUnresolvableConfigurationIsResolvedThenResolutionSucceeds() { void whenAResolvableCopyOfAnUnresolvableConfigurationIsResolvedThenResolutionSucceeds() {
Assumptions.assumeTrue(this.gradleBuild.gradleVersionIsLessThan("9.0-milestone-1"));
this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.0").build("build"); this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.0").build("build");
} }

View File

@ -134,6 +134,10 @@ public class GradleBuild {
return GradleVersion.version(this.gradleVersion).compareTo(GradleVersion.version(version)) >= 0; return GradleVersion.version(this.gradleVersion).compareTo(GradleVersion.version(version)) >= 0;
} }
public boolean gradleVersionIsLessThan(String version) {
return GradleVersion.version(this.gradleVersion).compareTo(GradleVersion.version(version)) < 0;
}
public BuildResult build(String... arguments) { public BuildResult build(String... arguments) {
try { try {
BuildResult result = prepareRunner(arguments).build(); BuildResult result = prepareRunner(arguments).build();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,18 +34,18 @@ public final class GradleVersions {
public static List<String> allCompatible() { public static List<String> allCompatible() {
if (isJavaVersion(JavaVersion.VERSION_24)) { if (isJavaVersion(JavaVersion.VERSION_24)) {
return Arrays.asList(GradleVersion.current().getVersion()); return Arrays.asList(GradleVersion.current().getVersion(), "9.0.0-milestone-9");
} }
if (isJavaVersion(JavaVersion.VERSION_23)) { if (isJavaVersion(JavaVersion.VERSION_23)) {
return Arrays.asList("8.10", GradleVersion.current().getVersion()); return Arrays.asList(GradleVersion.current().getVersion(), "9.0.0-milestone-9");
} }
if (isJavaVersion(JavaVersion.VERSION_22)) { if (isJavaVersion(JavaVersion.VERSION_22)) {
return Arrays.asList("8.8", GradleVersion.current().getVersion()); return Arrays.asList("8.8", GradleVersion.current().getVersion(), "9.0.0-milestone-9");
} }
if (isJavaVersion(JavaVersion.VERSION_21)) { if (isJavaVersion(JavaVersion.VERSION_21)) {
return Arrays.asList("8.5", GradleVersion.current().getVersion()); return Arrays.asList("8.5", GradleVersion.current().getVersion(), "9.0.0-milestone-9");
} }
return Arrays.asList("7.6.4", "8.4", GradleVersion.current().getVersion()); return Arrays.asList("7.6.4", "8.4", GradleVersion.current().getVersion(), "9.0.0-milestone-9");
} }
public static String minimumCompatible() { public static String minimumCompatible() {