Dependencies and Exclusions

I’m confused by the behavior of the jsr305 exclusion with the following:

  compile (group: 'com.google.guava', name: 'guava', version: '25.1-jre') {
     exclude group: 'com.google.code.findbugs', module: 'jsr305'
  }
  compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava', version: '2.6.0'

If I have only the following in my build.gradle jsr305 is excluded:

  compile (group: 'com.google.guava', name: 'guava', version: '25.1-jre') {
     exclude group: 'com.google.code.findbugs', module: 'jsr305'
  }

However if I have the following, jsr305 is now included

  compile (group: 'com.google.guava', name: 'guava', version: '25.1-jre') {
     exclude group: 'com.google.code.findbugs', module: 'jsr305'
  }
  compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava', version: '2.6.0'

Why is the exclude rule not being applied when both dependencies are defined?

I don’t know if I can answer my own question but this explained by


Duplicate of https://github.com/gradle/gradle/issues/1473