Skip to content

Commit 398993e

Browse files
committed
Fix Gradle configuration cache issue in DockerBuildImage tasks
Remove script-level mutable collection reference from DockerBuildImage task actions which is not compatible with Gradle configuration cache. Instead, collect image names at configuration time and pass them directly to the pushMatrix task.
1 parent 3a528c3 commit 398993e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

smoke-tests/images/servlet/build.gradle.kts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ val targets = mapOf(
177177
),
178178
)
179179

180-
val matrix = mutableListOf<String>()
181-
182180
tasks {
183181
val buildLinuxTestImages by registering {
184182
group = "build"
@@ -190,17 +188,17 @@ tasks {
190188
description = "Builds all Windows Docker images for the test matrix"
191189
}
192190

191+
val linuxImages = createDockerTasks(buildLinuxTestImages, false)
192+
val windowsImages = createDockerTasks(buildWindowsTestImages, true)
193+
193194
val pushMatrix by registering(DockerPushImage::class) {
194195
mustRunAfter(buildLinuxTestImages)
195196
mustRunAfter(buildWindowsTestImages)
196197
group = "publishing"
197198
description = "Push all Docker images for the test matrix"
198-
images.set(matrix)
199+
images.set(linuxImages + windowsImages)
199200
}
200201

201-
createDockerTasks(buildLinuxTestImages, false)
202-
createDockerTasks(buildWindowsTestImages, true)
203-
204202
val printSmokeTestsConfigurations by registering {
205203
doFirst {
206204
for ((server, matrices) in targets) {
@@ -357,9 +355,6 @@ fun configureImage(
357355
images.add(image)
358356
dockerFile.set(File(dockerWorkingDir.get().asFile, dockerFileName))
359357
buildArgs.set(extraArgs + mapOf("jdk" to jdk, "vm" to vm, "version" to version, "jdkImageName" to jdkImageName, "jdkImageHash" to jdkImageHash, "imageHash" to serverImageHash))
360-
doLast {
361-
matrix.add(image)
362-
}
363358
}
364359

365360
parentTask.configure {
@@ -368,7 +363,7 @@ fun configureImage(
368363
return image
369364
}
370365

371-
fun createDockerTasks(parentTask: TaskProvider<out Task>, isWindows: Boolean) {
366+
fun createDockerTasks(parentTask: TaskProvider<out Task>, isWindows: Boolean): Set<String> {
372367
val resultImages = mutableSetOf<String>()
373368
for ((server, matrices) in targets) {
374369
val smokeTestServer = findProperty("smokeTestServer")
@@ -397,4 +392,5 @@ fun createDockerTasks(parentTask: TaskProvider<out Task>, isWindows: Boolean) {
397392
}
398393
}
399394
}
395+
return resultImages
400396
}

0 commit comments

Comments
 (0)