Skip to content

Commit c383dc5

Browse files
authored
Fix gradle change detection for config tasks (#8181)
1 parent 132e868 commit c383dc5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

sdk-extensions/incubator/build.gradle.kts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,20 @@ val buildDirectory = layout.buildDirectory.asFile.get()
6464

6565
val downloadConfigurationSchema by tasks.registering(Download::class) {
6666
src(configurationRepoZip)
67-
dest("$buildDirectory/configuration/opentelemetry-configuration.zip")
67+
// The version is encoded in the filename so that a configurationTag change results in a new
68+
// path that doesn't yet exist, triggering a fresh download. On subsequent builds with the same
69+
// tag the file already exists and overwrite(false) skips the network request. Note: the
70+
// de.undercouch Download task always reports itself as not up-to-date, so overwrite(false) is
71+
// the intended mechanism for avoiding redundant downloads.
72+
//
73+
// The zip is stored in tmp/ so it is outside the Sync task's output directory (configuration/).
74+
dest("$buildDirectory/tmp/opentelemetry-configuration-v$configurationTag.zip")
6875
overwrite(false)
6976
}
7077

71-
val unzipConfigurationSchema by tasks.registering(Copy::class) {
78+
val unzipConfigurationSchema by tasks.registering(Sync::class) {
79+
// Sync (not Copy) removes stale files from the destination when the source changes, ensuring
80+
// files deleted or renamed between schema versions don't linger in the build dir.
7281
dependsOn(downloadConfigurationSchema)
7382

7483
from(zipTree(downloadConfigurationSchema.get().dest))
@@ -78,6 +87,7 @@ val unzipConfigurationSchema by tasks.registering(Copy::class) {
7887
path = pathParts.subList(1, pathParts.size).joinToString("/")
7988
})
8089
into("$buildDirectory/configuration/")
90+
includeEmptyDirs = false
8191
}
8292

8393
jsonSchema2Pojo {

0 commit comments

Comments
 (0)