Skip to content

Instantly share code, notes, and snippets.

@ghale
Last active July 19, 2023 11:13
Show Gist options
  • Save ghale/324225854672e85131da0aa73857c1ce to your computer and use it in GitHub Desktop.
Save ghale/324225854672e85131da0aa73857c1ce to your computer and use it in GitHub Desktop.
Capture task classpath fingerprints
def fingerprinter = services.get(org.gradle.internal.fingerprint.classpath.ClasspathFingerprinter)
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { task ->
doFirst {
ClassLoader classLoader = task.getClass().classLoader
while (classLoader instanceof URLClassLoader) {
def fingerprints = [] as Set
def allFiles = [] as Set
classLoader.getURLs().each {
fingerprints.add(["${task.path}:${file(it.file).name}", "${fingerprinter.fingerprint(files(it.file)).hash}"])
allFiles.add(file(it.file))
}
fingerprints.each { buildScan.value it[0], it[1] }
buildScan.value "${task.path}:classpath", allFiles.join("\n")
classLoader = classLoader.parent
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment