From fb00781307febfe68b96ff92b6c519e78ff27ee1 Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 24 Aug 2024 19:32:25 -0700 Subject: [PATCH] chore(build): Correctly set version restrictions on different Gradle versions also bring in cross-version testing --- build.gradle.kts | 18 +++++++++++++++++- gradle/libs.versions.toml | 2 +- .../build/SpongeGradleFunctionalTest.java | 7 ++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 664943e..ae88631 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,6 +22,8 @@ subprojects { apply(plugin = "net.kyori.indra.licenser.spotless") apply(plugin = "net.kyori.indra.git") + val indra = extensions.getByType(IndraExtension::class) + val testTargets = listOf(11, 17, 21) if (project.name != "spongegradle-testlib") { plugins.apply(JavaGradlePluginPlugin::class) apply(plugin = "com.gradle.plugin-publish") @@ -43,6 +45,16 @@ subprojects { implementation(project(":spongegradle-testlib")) } testType.set(TestSuiteType.FUNCTIONAL_TEST) + targets { + testTargets.forEach { runtimeVersion -> + register("functionalTestJava$runtimeVersion") { + testTask.configure { + javaLauncher = project.extensions.getByType(JavaToolchainService::class).launcherFor { languageVersion = JavaLanguageVersion.of(runtimeVersion) } + onlyIf { JavaVersion.current().ordinal + 1 != runtimeVersion && indra.javaVersions().strictVersions().get() } + } + } + } + } } tasks.named("check") { @@ -71,13 +83,17 @@ subprojects { ) } - extensions.configure(IndraExtension::class) { + with(indra) { github("SpongePowered", "SpongeGradle") { ci(true) publishing(true) } mitLicense() + javaVersions { + testWith().addAll(testTargets) + } + configurePublications { pom { developers { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5344ed8..9d2e33d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ indra = "3.1.3" pluginPublish = "1.2.1" spotless = "6.25.0" junit = "5.9.3" -mammoth = "1.3.1" +mammoth = "1.4.0" [libraries] gson = { module = "com.google.code.gson:gson", version = "2.11.0" } diff --git a/testlib/src/main/java/org/spongepowered/gradle/build/SpongeGradleFunctionalTest.java b/testlib/src/main/java/org/spongepowered/gradle/build/SpongeGradleFunctionalTest.java index a7f7d02..89ef275 100644 --- a/testlib/src/main/java/org/spongepowered/gradle/build/SpongeGradleFunctionalTest.java +++ b/testlib/src/main/java/org/spongepowered/gradle/build/SpongeGradleFunctionalTest.java @@ -40,9 +40,10 @@ */ @GradleFunctionalTest @GradleParameters({"--warning-mode", "fail", "--stacktrace"}) -@TestVariant(gradleVersion = "7.5.1") -@TestVariant(gradleVersion = "7.5.1", extraArguments = "--configuration-cache") -@TestVariantResource(value = "/injected-gradle-versions", optional = true) +@TestVariant(gradleVersion = "7.6.4", maximumRuntimeVersion = 20) +@TestVariant(gradleVersion = "7.6.4", extraArguments = "--configuration-cache", maximumRuntimeVersion = 20) +@TestVariant(gradleVersion = "8.10", extraArguments = "--configuration-cache", minimumRuntimeVersion = 17) +@TestVariantResource(value = "/injected-gradle-versions", optional = true, minimumRuntimeVersion = 17) @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})