Skip to content

Commit e7e1656

Browse files
committed
Fix gradle configuration cache issues for gradle-compatibility
1 parent 87ec8ee commit e7e1656

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

build-logic/src/main/kotlin/pklGradlePluginTest.gradle.kts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,29 @@ fun createCompatibilityTestTask(versionInfo: GradleVersionInfo): TaskProvider<Te
9393
createCompatibilityTestTask(versionInfo.version, versionInfo.downloadUrl)
9494

9595
fun createCompatibilityTestTask(version: String, downloadUrl: String): TaskProvider<Test> {
96+
val currentGradleVersion = gradle.gradleVersion
9697
return tasks.register("compatibilityTest$version", Test::class.java) {
9798
mustRunAfter(tasks.test)
9899

99-
maxHeapSize = tasks.test.get().maxHeapSize
100-
jvmArgs = tasks.test.get().jvmArgs
101-
classpath = tasks.test.get().classpath
100+
val myMaxHeapSize = tasks.test.map { it.maxHeapSize }
101+
val myJvmArgs = tasks.test.map { it.jvmArgs }
102+
val myClasspath = tasks.test.map { it.classpath }
103+
102104
systemProperty("testGradleVersion", version)
103105
systemProperty("testGradleDistributionUrl", downloadUrl)
104106

105107
doFirst {
106-
if (version == gradle.gradleVersion && gradle.taskGraph.hasTask(tasks.test.get())) {
108+
if (
109+
version == currentGradleVersion &&
110+
project.gradle.taskGraph.hasTask(project.tasks.getByName("test"))
111+
) {
107112
// don't test same version twice
108113
println("This version has already been tested by the `test` task.")
109114
throw StopExecutionException()
110115
}
116+
maxHeapSize = myMaxHeapSize.get()
117+
jvmArgs = myJvmArgs.get()
118+
classpath = myClasspath.get()
111119
}
112120
}
113121
}

0 commit comments

Comments
 (0)