有这个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
}
}
Run Code Online (Sandbox Code Playgroud)
我期望这场战争:
WEB-INF/
WEB-INF/lib/
WEB-INF/lib/commons-httpclient-3.1.jar
Run Code Online (Sandbox Code Playgroud)
但只有这样:
WEB-INF/
Run Code Online (Sandbox Code Playgroud)
如果我取消评论2nd exclude并评论1st exclude,那么它将按需要工作。
如果这是预期的行为,那么我如何才能从提供的库中全局排除特定的传递对象?
事实证明,这是发生的“正确”事情,compile实际上是从providedCompile:
apply plugin: 'war'
configurations.compile.extendsFrom.each {
println "$it"
}
Run Code Online (Sandbox Code Playgroud)
因此,我的解决方案如下:
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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1043 次 |
| 最近记录: |