Skip to content

Commit 2c4dcad

Browse files
committed
Updated test case for old Gradle/kotlin versions
1 parent e879726 commit 2c4dcad

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

build.gradle.kts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ group = "org.gradlex"
88
version = "1.13.1"
99

1010
java {
11-
toolchain.languageVersion = JavaLanguageVersion.of(17)
12-
sourceCompatibility = JavaVersion.VERSION_1_8
13-
targetCompatibility = JavaVersion.VERSION_1_8
11+
toolchain.languageVersion = JavaLanguageVersion.of(11)
1412
}
1513

1614
dependencies {
@@ -36,27 +34,31 @@ pluginPublishConventions {
3634
}
3735
}
3836

39-
tasks.withType<Test>().configureEach {
40-
group = "verification"
41-
classpath = sourceSets.test.get().runtimeClasspath
42-
testClassesDirs = sourceSets.test.get().output.classesDirs
43-
useJUnitPlatform()
44-
maxParallelForks = 4
45-
}
46-
47-
tasks.named("test") {
37+
tasks.named<Test>("test") {
4838
description = "Runs tests against the Gradle version the plugin is built with"
4939
}
5040

5141
listOf("6.8.3", "6.9.4", "7.6.5", "8.14.2").forEach { gradleVersionUnderTest ->
5242
val testGradle = tasks.register<Test>("testGradle$gradleVersionUnderTest") {
5343
description = "Runs tests against Gradle $gradleVersionUnderTest"
5444
systemProperty("gradleVersionUnderTest", gradleVersionUnderTest)
55-
if (gradleVersionUnderTest.startsWith("6")) {
56-
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(11) }
57-
}
5845
}
5946
tasks.check {
6047
dependsOn(testGradle)
6148
}
6249
}
50+
51+
tasks.withType<Test>().configureEach {
52+
group = "verification"
53+
classpath = sourceSets.test.get().runtimeClasspath
54+
testClassesDirs = sourceSets.test.get().output.classesDirs
55+
useJUnitPlatform()
56+
maxParallelForks = 4
57+
58+
val gradleMajorVersion = (systemProperties["gradleVersionUnderTest"] as String? ?: gradle.gradleVersion).split(".")[0].toInt()
59+
if (gradleMajorVersion >= 7) {
60+
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) }
61+
} else {
62+
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(11) }
63+
}
64+
}

src/test/groovy/org/gradlex/javamodule/moduleinfo/test/RequireAllDefinedDependenciesFunctionalTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class RequireAllDefinedDependenciesFunctionalTest extends Specification {
374374
given:
375375
def sharedBuildScript = """
376376
extraJavaModuleInfo {
377-
versionsProvidingConfiguration = project.provider { project.configurations.named("mainRuntimeClasspath").get() }
377+
versionsProvidingConfiguration.set(project.provider { project.configurations.named("mainRuntimeClasspath").get() })
378378
module(${libs.commonsHttpClient}, "org.apache.httpcomponents.httpclient")
379379
module(${libs.commonsLogging}, "org.apache.commons.logging")
380380
knownModule("commons-codec:commons-codec", "org.apache.commons.codec")

0 commit comments

Comments
 (0)