1

In my build.gradle.kts I am doing text replacement while extracting an archive. I am using filesMatching to do the replacement.

My problem is that when I replace the "Your Momma" in the script source with something else and rerun the task, Gradle still reports it as up-to-date, instead of scraping the unzipped dir and redoing the replacement operation.

> Task :downloadZipFile
Download https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip

> Task :downloadAndUnzipFile UP-TO-DATE

My build.gradle.kts is

import de.undercouch.gradle.tasks.download.Download

group = "org.example"
version = "1.0-SNAPSHOT"

plugins {
    id("de.undercouch.download").version("4.0.4")
}

tasks {
    val downloadZipFile by registering(Download::class) {
        src("https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip")
        dest(File(buildDir, "1.0.zip"))
    }

    val downloadAndUnzipFile by registering(Copy::class) {
        dependsOn(downloadZipFile)
        from(zipTree(downloadZipFile.get().dest))
        into(buildDir)

        val replacement = "Your Momma"
        val spec = project.copySpec {
            this.filter { _: String -> replacement }
        }

        filesMatching("**/*.txt") {
            with(spec)
        }
    }
}

I also tried to use a project property as the source of the replacement text, and change in its value does not invalidate the cache either.

        val replacement = project.findProperty("replacement") as String
user7610
  • 25,267
  • 15
  • 124
  • 150

0 Answers0