Breaking change regarding "exclude group" between Gradle 1.12 and 2.3 RC2

Hi,

Could you maybe clarify the following breaking change that I discovered while upgrading our project from Gradle 1.12 to 2.3 RC2:

For one of our modules we have to exclude a few transitive dependencies and the following dependency declaration was working so far:

testCompile ("org.springframework:spring-jms:$springVersion") {
   exclude group: 'org.springframework'
  }

Please notice, that the group of the primary dependency and the exclude group are the same. Basically, we want to say include this dependency but exclude all other dependencies of the same group.

Once upgraded to Gradle 2.3 RC3, this does not work anymore. Instead EVERYTHING from that group is excluded, INCLUDING the primary dependency. In order to fix this I have to declare:

testCompile ("org.springframework:spring-jms:$springVersion") {
   exclude group: 'org.springframework', module: 'spring-aop'
   exclude group: 'org.springframework', module: 'spring-beans'
   exclude group: 'org.springframework', module: 'spring-context'
   exclude group: 'org.springframework', module: 'spring-core'
   exclude group: 'org.springframework', module: 'spring-messaging'
   exclude group: 'org.springframework', module: 'spring-tx'
  }

What is the reason for the changed behavior? Is it possibly a bug? I could see both sides of the coin here. However, it is more wordy. Is there another workaround?

This looks to have been an unintentional result of some changes made in 2.3 regarding Ivy module exclusions. The current plan is to revert back to the old behavior and put out another release candidate. Please look out for RC4 and try your build again.

Awesome - thanks!

Gunnar, can you confirm that 2.3-rc-4 fixes your issue?

Yes it does. Thanks! See also: https://github.com/spring-projects/spring-integration/pull/1369

Great! I believe the current plan is to release Monday, assuming no further regressions are identified.

In the 2.3 release version, this appears to still be an issue. I’m getting full exclusion of not just transitive dependencies, but the primary itself.

compile (‘com.mycompany:MyCompanyJar:1.0’) {

exclude module: ‘*’ }

Doing this, MyCompanyJar is not added to the classpath/pulled from our repo. The behavior in 2.2.1 was to get MyCompanyJar but not its dependencies. Is this a bug or a new definition of how it should work?

Are you using an Ivy or Maven repository? Alternatively you could simply disable transitive dependencies rather than using a wildcard exclude:

compile(‘com.mycompany:mycompanyjar:1.0’) {

transitive false

}

Hi Mark,

Thanks for the reply. We are using a Maven repository. I’ll try your suggestion.

Thanks -Chris

I’m not able to reproduce this against artifacts in maven central in 2.3. Can you provide a reproducible example?

Hi Mark,

Dug a little more and I believe this might (somehow) be an Eclipse problem. Using your suggestion

transitive false

Provides the correct jars when running task distZip from either the command line or through Eclipse. Changing this to

exclude module: ‘*’

will produce an identical result running distZip on the command line, but will miss the jar when running distZip from Eclipse.

I don’t have much of an understanding how the Eclipse plug-in works with Gradle and this seems really bizarre to me. Let me know if I can provide something else to you.

Thanks -Chris