如何获得gradle以输出每个依赖项的依赖项哈希 [英] How to get gradle to output dependency hash for each dependency

查看:152
本文介绍了如何获得gradle以输出每个依赖项的依赖项哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有生以来第一次看到一种情况

I am seeing, for the first time in my life, a situation where

gradle compileJava check在本地运行良好,但是当我尝试使用bitbucket管道运行相同的命令时,得到NoSuchClassDefError

gradle compileJava check runs fine locally but when I try to run the same commands with bitbucket pipelines I get NoSuchClassDefError

我在本地和管道上进行gradle user-login-server:dependencies,我怀疑的工件的版本是相同的

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.

因此:如何强制gradle输出每个依赖项的哈希值,以便我能找出问题所在?

Hence: How can I force gradle to output the hash of every dependency so I can trackdown what's going wrong?

推荐答案

您可以遍历jar并像这样打印出哈希.

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)}" }
    }
}

这篇关于如何获得gradle以输出每个依赖项的依赖项哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆