gradle war:如何强制包含可传递提供的dep?

gradle war:如何强制包含可传递提供的dep?,gradle,Gradle,拥有这个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 doe

拥有这个
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
    }
}
apply plugin: 'war'

configurations.compile.extendsFrom.each {
    println "$it"
}
我期待这场战争:

WEB-INF/
WEB-INF/lib/
WEB-INF/lib/commons-httpclient-3.1.jar
但只有这样:

WEB-INF/
如果我取消注释2nd
exclude
和注释1st
exclude
,它将根据需要工作


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

事实证明,这是“正确”的做法,因为
compile
实际上是从
providedCompile
扩展而来的:

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
    }
}
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
}

事实证明,这是“正确”的做法,因为
compile
实际上是从
providedCompile
扩展而来的:

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
    }
}
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
}