Fix gradle configuration cache issues for gradle-compatibility (#1658)

This commit is contained in:
Daniel Chao
2026-06-05 14:17:06 -07:00
committed by GitHub
parent 01f8fcae7b
commit bb07589eae
@@ -93,21 +93,29 @@ fun createCompatibilityTestTask(versionInfo: GradleVersionInfo): TaskProvider<Te
createCompatibilityTestTask(versionInfo.version, versionInfo.downloadUrl) createCompatibilityTestTask(versionInfo.version, versionInfo.downloadUrl)
fun createCompatibilityTestTask(version: String, downloadUrl: String): TaskProvider<Test> { fun createCompatibilityTestTask(version: String, downloadUrl: String): TaskProvider<Test> {
val currentGradleVersion = gradle.gradleVersion
return tasks.register("compatibilityTest$version", Test::class.java) { return tasks.register("compatibilityTest$version", Test::class.java) {
mustRunAfter(tasks.test) mustRunAfter(tasks.test)
maxHeapSize = tasks.test.get().maxHeapSize val myMaxHeapSize = tasks.test.map { it.maxHeapSize }
jvmArgs = tasks.test.get().jvmArgs val myJvmArgs = tasks.test.map { it.jvmArgs }
classpath = tasks.test.get().classpath val myClasspath = tasks.test.map { it.classpath }
systemProperty("testGradleVersion", version) systemProperty("testGradleVersion", version)
systemProperty("testGradleDistributionUrl", downloadUrl) systemProperty("testGradleDistributionUrl", downloadUrl)
doFirst { doFirst {
if (version == gradle.gradleVersion && gradle.taskGraph.hasTask(tasks.test.get())) { if (
version == currentGradleVersion &&
project.gradle.taskGraph.hasTask(project.tasks.getByName("test"))
) {
// don't test same version twice // don't test same version twice
println("This version has already been tested by the `test` task.") println("This version has already been tested by the `test` task.")
throw StopExecutionException() throw StopExecutionException()
} }
maxHeapSize = myMaxHeapSize.get()
jvmArgs = myJvmArgs.get()
classpath = myClasspath.get()
} }
} }
} }