有了这个build.gradle
:
apply plugin: 'war'
repositories {
mavenCentral()
maven { url "http://repository.jboss.org/nexus/content/groups/public" }
}
configurations {
providedCompile {
exclude module: 'commons-httpclient' // here it doesn't work
}
}
dependencies {
compile 'commons-httpclient:commons-httpclient:3.1'
providedCompile ('org.jboss.resteasy:resteasy-jaxrs:2.3.3.Final') {
//exclude module: 'commons-httpclient' // here it works
}
}
我预计会有这场 war :
WEB-INF/
WEB-INF/lib/
WEB-INF/lib/commons-httpclient-3.1.jar
但只有这个:
WEB-INF/
如果我取消注释第二个排除
并注释第一个排除
,它会根据需要工作。
如果这是预期的行为,我怎样才能从提供的库中全局排除特定的传递性?
最佳答案
事实证明,这是“正确”发生的事情,因为 compile
实际上是从 providedCompile
扩展而来的:
apply plugin: 'war'
configurations.compile.extendsFrom.each {
println "$it"
}
所以,我的解决方案如下:
apply plugin: 'war'
repositories {
mavenCentral()
maven { url "http://repository.jboss.org/nexus/content/groups/public" }
}
configurations {
forceInclude {}
}
dependencies {
providedCompile 'org.jboss.resteasy:resteasy-jaxrs:2.3.3.Final'
forceInclude 'commons-httpclient:commons-httpclient:3.1'
}
war {
classpath += configurations.forceInclude
}
关于梯度 war : how to force inclusion of transitively provided dep?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12687672/