Last active
July 19, 2023 11:13
-
-
Save ghale/324225854672e85131da0aa73857c1ce to your computer and use it in GitHub Desktop.
Capture task classpath fingerprints
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
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