Revert configuration cache (#1659)

This reverts the commits that enabled Gradle's configuration cache
feature.

IMO: this feature is too hard to use. We don't know if a task is valid
for the configuration cache until it runs, and it's very hard to tell if
something is safe when authoring Gradle code.
For example, our publish tasks are currently failing; I don't know how I
would fix this without running the publish task again on my dev machine.

Also, some of our build scripts become more brittle because of this; for
example, see
https://github.com/apple/pkl/blob/bb07589eae0b3195a589559a3245cbc12c29b394/build-logic/src/main/kotlin/BuildInfo.kt#L291-L296
This commit is contained in:
Daniel Chao
2026-06-05 16:31:40 -07:00
committed by GitHub
parent bb07589eae
commit 1cc20b611f
21 changed files with 180 additions and 307 deletions
+24 -19
View File
@@ -70,26 +70,17 @@ for (packageDir in file("src/main/files/packages").listFiles()!!) {
into(destinationDir)
val shasumFile = destinationDir.map { it.file("${packageDir.name}.json.sha256") }
outputs.file(shasumFile)
val isWindows = buildInfo.os.isWindows
filter { line ->
line.replaceFirst("\$computedChecksum", archiveFile.get().asFile.computeChecksum())
}
doLast {
val outputFile = destinationDir.get().asFile.resolve("${packageDir.name}.json")
fun sha256Hex(file: File): String {
val hash = MessageDigest.getInstance("SHA-256").digest(file.readBytes())
return buildString(hash.size * 2) {
for (b in hash) {
append("0123456789abcdef"[b.toInt() shr 4 and 0xF])
append("0123456789abcdef"[b.toInt() and 0xF])
}
}
}
var contents =
outputFile.readText().replace("\$computedChecksum", sha256Hex(archiveFile.get().asFile))
if (isWindows) {
if (buildInfo.os.isWindows) {
val contents = outputFile.readText()
// workaround for https://github.com/gradle/gradle/issues/1151
contents = contents.replace("\r\n", "\n")
outputFile.writeText(contents.replace("\r\n", "\n"))
}
outputFile.writeText(contents)
shasumFile.get().asFile.writeText(sha256Hex(outputFile))
shasumFile.get().asFile.writeText(outputFile.computeChecksum())
}
}
@@ -120,9 +111,6 @@ val generateKeys by
"CN=localhost",
)
workingDir(keystoreDir)
// capture keystoreFile inside closure so we don't reference `this$0`; which breaks Gradle
// configuration cache
val keystoreFile = keystoreFile
doFirst {
workingDir.mkdirs()
keystoreFile.get().asFile.delete()
@@ -155,3 +143,20 @@ val exportCerts by
outputFile.get().asFile.delete()
}
}
fun toHex(hash: ByteArray): String {
val hexDigitTable =
charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f')
return buildString(hash.size * 2) {
for (b in hash) {
append(hexDigitTable[b.toInt() shr 4 and 0xF])
append(hexDigitTable[b.toInt() and 0xF])
}
}
}
fun File.computeChecksum(): String {
val md = MessageDigest.getInstance("SHA-256")
val hash = md.digest(readBytes())
return toHex(hash)
}