Transitive dependency rules when configurations depend on each other

I have a configuration “hdp” defined for a set of jars. This configuration has transitive set to false. If i add this configuration as a part of the standard compile configuration, all of the dependencies for the hdp jars get loaded as well. Is there a way to enforce this transitive value of false while still using the configuration as part of the compile?

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'sentinel-rest-service'
    version =  '0.1.0'
}

//Vendor versions
def hive_version="0.13.0.2.1.2.0-402"
def hadoop_version="2.4.0.2.1.2.0-402"
def oozie_version="4.0.0.2.1.11.0-891"


sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")

    testCompile("junit:junit")
}

configurations.create('hdp')
configurations.hdp {
    transitive = false

}


task printDependencies << {
    configurations.hdp.dependencies.each { dep -> println dep.name }
    println()

    configurations.compile.dependencies.each { dep -> println dep.name }
    println()

    configurations.compile.allDependencies.each { dep -> println dep.name }
    println()

}


List hdpJarList = [
        'org.apache.pig:pig:0.12.1',
        'org.apache.thrift:libfb303:0.9.0',
        'org.mortbay.jetty:jetty-util:6.1.26',
        'org.apache.httpcomponents:httpcore:4.2.5',
        'org.codehaus.jackson:jackson-core-asl:1.8.8',
        "org.apache.hive:hive-service:$hive_version",
        "org.apache.hive:hive-serde:$hive_version",
        "org.apache.hive:hive-metastore:$hive_version",
        "org.apache.hive:hive-jdbc:$hive_version",
        "org.apache.hive:hive-exec:$hive_version",
        "org.apache.hive:hive-common:$hive_version",
        "org.apache.hive.hcatalog:hive-hcatalog-core:$hive_version",
        "org.apache.hadoop:hadoop-mapreduce-client-core:$hadoop_version",
        "org.apache.hadoop:hadoop-mapreduce-client-common:$hadoop_version",
        "org.apache.hadoop:hadoop-hdfs:$hadoop_version",
        "org.apache.hadoop:hadoop-common:$hadoop_version",
        "org.apache.hadoop:hadoop-auth:$hadoop_version",
        "org.apache.hadoop:hadoop-yarn-common:$hadoop_version",
        "org.apache.hadoop:hadoop-yarn-api:$hadoop_version",
        'com.google.guava:guava:11.0.2',
        'org.datanucleus:datanucleus-core:3.2.10',
        'commons-logging:commons-logging:1.1.3',
        'commons-lang:commons-lang:2.6',
        'commons-configuration:commons-configuration:1.6',
        'commons-codec:commons-codec:1.4',
        'commons-cli:commons-cli:1.2',
        'commons-collections:commons-collections:3.2.1',
        "org.apache.oozie:oozie-client:$oozie_version"]

dependencies {
    hdp hdpJarList
    compile (configurations.hdp){
        transitive = false
    }


}

task wrapper(type: Wrapper) {
    gradleVersion = '2.7'
}

The transitive flag on the configuration is not passed along when you add the configuration to another configuration (i.e. this essentially just makes the dependencies part of both configurations). What you can do, however, is set each dependency to not be transitive and this will get passed to the other configuration because it’s a setting on the dependency itself. For example:

dependencies {
    hdpJarList.each { hdp(it) { transitive = false } }
    compile configurations.hdp
}

Thanks a lot!! That was exactly what i was looking for! :sunglasses: