Transitive dependencies with project dependencies

I’m testing Gradle to see if it suits my needs.

So, in my test project, I have subprojects test-war and test-jar. The test-jar is a Java project which creates a jar. The test-war is a web project which depends on test-jar (it will include test-jar in its WEB-INF/lib).

The test-jar has a compile dependency on a 3rd party jar.

test-war => test-jar => 3rdparty-jar.

The test-war/build.gradle looks like this:

apply plugin: 'war'
  dependencies {
 compile project('test-jar') {
  transitive = false
 }
}

The test-jar looks like this:

apply plugin: 'java'
  dependencies {
 compile name: '3rdparty-jar', group: 'somegroup', version: 'latest.integration'
}

With this setting, the test-jar goes into the WEB-INF/lib of test-war. But the problem is that the 3rdparty-jar goes to WEB-INF/lib as well and I don’t want it there (it goes to ear’s APP-INF/lib).

Does the "transitive=false’ not work with project dependencies?

Ah, I got it working. It should have been:

apply plugin: 'war'
dependencies {
    compile (project('test-jar')) {
        transitive = false
    }
}
1 Like