问题
I am seeing, for the first time in my life, a situation where
gradle compileJava check
runs fine locally but when I try to run the same commands with bitbucket pipelines I get NoSuchClassDefError
I do gradle user-login-server:dependencies
locally and on pipelines and the versions for the artifacts I suspect are identical
So the only explanation I can come up with is that the actual artifacts are different.
Hence: How can I force gradle to output the hash of every dependency so I can trackdown what's going wrong?
回答1:
You could loop across the jars and print out a hash like so.
task printDependencyHashes() {
def hash = { File file ->
def md = java.security.MessageDigest.getInstance('MD5')
file.eachByte(1024 * 4) { buffer, len ->
md.update(buffer, 0, len)
}
return md.digest().encodeHex().toString()
}
doLast {
configurations.compileClasspath.each { println "${it.name}: ${hash(it)}" }
}
}
来源:https://stackoverflow.com/questions/45248234/how-to-get-gradle-to-output-dependency-hash-for-each-dependency