How set transitive = false option for multiple modules (global approach)

Hello developers…

Working with Gradle 2.13 and with a project with multiple modules

I could have the following:

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

I can confirm that the transitive dependencies are referenced, according with my research I can avoid that using transitive = false how for example:

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

Until here I am ok with this, but if a module depends on many other modules, I want avoid the following (is verbose)

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

How you can see I am using many times the transitive = false for each compile project(':module-something'). And it just for one module, I could have other modules with the same situation.

Is there a global special configuration where I can use compile project(':module-xyz') and it automatically defaults to transitive = false? (it from the global special configuration)

I did a research, where I should use

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

I have tried that in:

  • root level
  • within all projects{} section
  • within subprojects{} section

and nothing, my unique way is setting transitive = false for each compile project(':module-something') within a module