Skip to content

Commit fb00781

Browse files
committed
chore(build): Correctly set version restrictions on different Gradle versions
also bring in cross-version testing
1 parent 10e52e7 commit fb00781

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

build.gradle.kts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ subprojects {
2222
apply(plugin = "net.kyori.indra.licenser.spotless")
2323
apply(plugin = "net.kyori.indra.git")
2424

25+
val indra = extensions.getByType(IndraExtension::class)
26+
val testTargets = listOf(11, 17, 21)
2527
if (project.name != "spongegradle-testlib") {
2628
plugins.apply(JavaGradlePluginPlugin::class)
2729
apply(plugin = "com.gradle.plugin-publish")
@@ -43,6 +45,16 @@ subprojects {
4345
implementation(project(":spongegradle-testlib"))
4446
}
4547
testType.set(TestSuiteType.FUNCTIONAL_TEST)
48+
targets {
49+
testTargets.forEach { runtimeVersion ->
50+
register("functionalTestJava$runtimeVersion") {
51+
testTask.configure {
52+
javaLauncher = project.extensions.getByType(JavaToolchainService::class).launcherFor { languageVersion = JavaLanguageVersion.of(runtimeVersion) }
53+
onlyIf { JavaVersion.current().ordinal + 1 != runtimeVersion && indra.javaVersions().strictVersions().get() }
54+
}
55+
}
56+
}
57+
}
4658
}
4759

4860
tasks.named("check") {
@@ -71,13 +83,17 @@ subprojects {
7183
)
7284
}
7385

74-
extensions.configure(IndraExtension::class) {
86+
with(indra) {
7587
github("SpongePowered", "SpongeGradle") {
7688
ci(true)
7789
publishing(true)
7890
}
7991
mitLicense()
8092

93+
javaVersions {
94+
testWith().addAll(testTargets)
95+
}
96+
8197
configurePublications {
8298
pom {
8399
developers {

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ indra = "3.1.3"
66
pluginPublish = "1.2.1"
77
spotless = "6.25.0"
88
junit = "5.9.3"
9-
mammoth = "1.3.1"
9+
mammoth = "1.4.0"
1010

1111
[libraries]
1212
gson = { module = "com.google.code.gson:gson", version = "2.11.0" }

testlib/src/main/java/org/spongepowered/gradle/build/SpongeGradleFunctionalTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
*/
4141
@GradleFunctionalTest
4242
@GradleParameters({"--warning-mode", "fail", "--stacktrace"})
43-
@TestVariant(gradleVersion = "7.5.1")
44-
@TestVariant(gradleVersion = "7.5.1", extraArguments = "--configuration-cache")
45-
@TestVariantResource(value = "/injected-gradle-versions", optional = true)
43+
@TestVariant(gradleVersion = "7.6.4", maximumRuntimeVersion = 20)
44+
@TestVariant(gradleVersion = "7.6.4", extraArguments = "--configuration-cache", maximumRuntimeVersion = 20)
45+
@TestVariant(gradleVersion = "8.10", extraArguments = "--configuration-cache", minimumRuntimeVersion = 17)
46+
@TestVariantResource(value = "/injected-gradle-versions", optional = true, minimumRuntimeVersion = 17)
4647
@Documented
4748
@Retention(RetentionPolicy.RUNTIME)
4849
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})

0 commit comments

Comments
 (0)