gpt4 book ai didi

gradle - 如何强制特定子项目的gradle依赖关系?

转载 作者:行者123 更新时间:2023-12-03 04:01:09 25 4
gpt4 key购买 nike

这是在做什么:

org.apache.santuario:xmlsec:1.5.7 -> 2.0.2 

仅针对此子项目,我要强制使用1.5.7。顺便说一句,这东西被埋得很深。必须有一个比剥洋葱更好的方法来排除一个依赖项。我的意思是,如果我有一个依赖项X,为什么我不能以编程方式级联下来进行排除呢?这是Gradle,对不对?

这几乎起作用了:
configurations {

compile.resolutionStrategy {
force 'org.apache.santuario:xmlsec:1.5.7'
}
...
}

以上内容正确显示在树中,但在 war 中仍显示2.0.2。

无论如何,只要有效且不需要手动进行挖掘,我都会接受。

最佳答案

您可以考虑使用force而不是substitute

dependencies {
compile 'org.apache.santuario:xmlsec:2.0.1'
}

configurations.all {
resolutionStrategy {
// add dependency substitution rules
dependencySubstitution {
substitute module('org.apache.santuario:xmlsec') with module('org.apache.santuario:xmlsec:1.5.7')
}
}
}

然后我得到一个输出:
$ ./gradlew -q dependencies --configuration compile

------------------------------------------------------------
Root project
------------------------------------------------------------

compile - Dependencies for source set 'main'.
\--- org.apache.santuario:xmlsec:2.0.1 -> 1.5.7
\--- commons-logging:commons-logging:1.1.1

关于gradle - 如何强制特定子项目的gradle依赖关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41271898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com