如何在Gradle中获取修补的.jar库的依赖关系? [英] How to get dependencies for a patched .jar library in Gradle?
问题描述
我们使用的是Selenium的修补版本,我们想将修补后的jar用作文件依赖项,同时从Maven存储库中获取Selenium的所有依赖项,而无需手动指定它们.这可能吗?
We are using a patched version of Selenium, and we'd like to use our patched jar as a file dependency while getting all the dependencies of Selenium from a Maven repo without specifying them manually. Is this possible?
今天,我们使用fileTree依赖项将修补后的硒罐及其依赖项添加为对我们项目的依赖项,但这并不理想,因为它很丑陋,有时还会使Gradle的冲突解决方式混乱.
Today we add the patched selenium jar together with it's dependencies as a dependency to our project using a fileTree dependency, but this is not ideal since it's ugly and also sometimes seem to mess up Gradle's conflict resolution.
推荐答案
通常,我建议将修补后的Jar发布到公司的Maven或Ivy存储库(Artifactory,Nexus等)中,并附带适当的依赖项.描述符.当然,还有其他解决方案,如下所示:
In general, I'd recommend to publish the patched Jar to your corporate Maven or Ivy repository (Artifactory, Nexus, etc.), along with a suitable dependency descriptor. Of course there are other solutions, like the following:
apply plugin: "java"
repositories {
mavenCentral()
}
configurations {
rawCompile
}
dependencies {
rawCompile "junit:junit:4.11"
compile configurations.rawCompile.filter { it.name != "junit-4.11.jar" }, files("lib/junit-4.11-patched.jar")
}
task debug << {
println "original dependencies: $configurations.rawCompile.files \n"
println "changed dependencies: $configurations.compile.files"
}
此解决方案和类似解决方案的潜在问题是文件依赖性(这是您在compile
上得到的结果)不参与解决冲突.
A potential problem with this and similar solutions is that file dependencies (which is what you end up with on compile
) don't participate in conflict resolution.
这篇关于如何在Gradle中获取修补的.jar库的依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!