Created
October 13, 2018 01:15
-
-
Save fuzzyweapon/9ffb20415afd0a970033039ccc8c20e3 to your computer and use it in GitHub Desktop.
Preserve last modified in copy actions in Gradle without using ant.copy task.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://github.com/gradle/kotlin-dsl/blob/70aca202558f2f6e43cd8ead3ec95d669bfd7b33/build.gradle.kts#L69 | |
// Preserve file modified dates without using ant.copy task | |
val copyCurrentDistro by task<Copy> { | |
description = "Copies the current Gradle distro into '$customInstallationDir'." | |
from(gradle.gradleHomeDir) | |
into(customInstallationDir) | |
exclude("**/*kotlin*") | |
// preserve last modified date on each file to make it easier | |
// to check which files were patched by next step | |
val copyDetails = mutableListOf<FileCopyDetails>() | |
eachFile { copyDetails.add(this) } | |
doLast { | |
copyDetails.forEach { details -> | |
File(customInstallationDir, details.path).setLastModified(details.lastModified) | |
} | |
} | |
// don't bother recreating it | |
onlyIf { !customInstallationDir.exists() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment