Excluding dependencies from dependent projects


(Paul Bennett) #1

I have two projects A and B. A adds the groovy plugin, B adds the war plugin. B has a dependency on A:

dependencies {
    compile project(':A')
}

I want to exclude a compile time dependency declared in A from the product of B A declares this dependency

dependencies {
    compile ':some-jar:1.0'
}

and resolves from a local library directory B tries to exclude this with

dependencies {
 compile(project(':A')) {
  exclude module: 'some-jar'
 }
}

However, the jar is still included in the resulting war file. How can I exclude it?

Thanks, Paul


(Paul Bennett) #2

OK, a little deeper reading, and I found the answer. I was trying to exclude a transitive dependeny on a module. I needed to re-work the compile configuration with

configurations.compile.exclude module: 'some-jar'

(sebtardif) #3

I think all the syntax that exist with[ ‘:some-jar:1.0’] to exclude should also work with [project(’:A’)], could we improve Gradle to do so?