3

我们在一个项目中有以下配置...

configurations {
    //compile.exclude module: 'commons'
    //all*.exclude group: 'org.gradle.test.excludes', module: 'reports'
    all*.exclude module: 'log4j'
}

dependencies {
    compile group: 'org.slf4j',          name: 'slf4j-api',               version: '1.6.6'
    compile group: 'org.slf4j',          name: 'log4j-over-slf4j',        version: '1.6.6'
    compile group: 'com.google.inject',  name: 'guice',                   version: '3.0'
    compile group: 'com.google.protobuf',name: 'protobuf-java',           version: '2.4.1'
    //compile group: 'org.asteriskjava',name: 'asterisk-java',         version: '1.0.0.M3'   

    //to be erased soon
    compile group: 'commons-configuration',name:'commons-configuration',version: '1.8'
    //compile group: 'org.bouncycastle',   name: 'bcpg-jdk16',              version: '1.46'

    compile project(':sdi-master')
    compile project(':sdi-webserver')
}

不幸的是,项目 sdi-webserver 有它自己的 log4j 从文件树中引入,就像这样

project(':sdi-webserver') {
    project.ext.genLibDir = file('lib')

    dependencies {    
        compile project(':sdi-master')
        compile fileTree(dir: '../webserver/lib', include: '*.jar')
        compile fileTree(dir: '../webserver/play-1.2.4/framework/lib', include: '*.jar')
        compile fileTree(dir: '../webserver/play-1.2.4/framework', include: 'play-*.jar')   
    }

我们如何排除这个 jar,使其不属于依赖项。以上排除了我们仅适用于存储库和传递依赖项并且不适用于fileTree,但我们仍然需要以某种方式排除jar文件,因为我们希望eclipse任务构建正确的.classpath,我们希望configurations.compile具有准确的信息复制罐子等

谢谢,院长

4

1 回答 1

5

只需使用excludeon fileTree。语法与 for 相同include

于 2012-09-28T23:47:35.143 回答