1

有这个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
    }
}

我希望有这场战争:

WEB-INF/
WEB-INF/lib/
WEB-INF/lib/commons-httpclient-3.1.jar

但只有这个:

WEB-INF/

如果我取消评论 2ndexclude并评论 1st exclude,它会根据需要工作。

如果这是预期的行为,我如何才能从提供的库中全局排除特定的传递?

4

1 回答 1

5

事实证明,这是发生的“正确”事情,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
}
于 2012-10-02T10:08:00.800 回答