Skip to content

Commit

Permalink
chore(build): Correctly set version restrictions on different Gradle …
Browse files Browse the repository at this point in the history
…versions

also bring in cross-version testing
  • Loading branch information
zml2008 committed Aug 25, 2024
1 parent 10e52e7 commit fb00781
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
18 changes: 17 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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") {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit fb00781

Please sign in to comment.