Gradle:为多个模块设置transitive = false选项

时间:2016-06-09 19:04:47

标签: gradle build.gradle

使用Gradle 2.13和包含多个模块的项目

我可以拥有以下内容:

project(':module-main') {
    description 'Main'
    dependencies {     
       compile project(':module-config')
       ['spring-context'].each { compile "org.springframework:$it:$springFrameworkVersion" }
    }
}

我可以确认引用了传递依赖,根据我的研究,我可以避免使用transitive = false例如:

project(':module-main') {
        description 'Main'
        dependencies {     
           compile (project(':module-config')){
               transitive = false
           }
           ['spring-context'].each { compile "org.springframework:$it:$springFrameworkVersion" }
        }
    }

直到这里我对此感到满意,但是如果一个模块依赖于许多其他模块,我想避免以下(详细)

project(':module-main') {
        description 'Main'
        dependencies {     
           compile (project(':module-config')){
               transitive = false
           }
           compile (project(':module-abc')){
               transitive = false
           }
           compile (project(':module-xyz')){
               transitive = false
           }
           ['spring-context'].each { compile "org.springframework:$it:$springFrameworkVersion" }
        }
    }

如何看待我多次使用transitive = false compile project(':module-xyz')。它只是一个模块,我可以有其他模块具有相同的情况。

是否有全局特殊配置我可以使用compile project(':module-xyz')并自动默认为transitive = false? (它来自全局特殊配置

我做了一项研究,我应该使用

configurations {
    compile {
            transitive false
    }
    testCompile {
            transitive false
    }
}

我已尝试过:

  • 根级别
  • all projects{}部分
  • subprojects{}部分

一无所获,我的独特方式是为模块中的每个transitive = false设置compile project(':module-something')

0 个答案:

没有答案
相关问题