Gradle excludes all transitive dependencies when ivy.xml uses exclude on 'type' or 'conf' attributes

Gradle 1.x is excluding all transitive dependencies whenever the dependency ivy.xml file has an exclude on other than group or module, for example:

<exclude type="foo" conf="bar"/>

org.gradle.api.internal.artifacts.ivyservice.resolveengine.ModuleVersionSpec.ExcludeRuleSpec.isSatisfiedBy(ModuleId) is always returning true when the above is present. The rule attributes look like this: {module=, artifact=, matcher=exact, organisation=, type=foo, ext=}. The mechanism used for rule matching only considers the module and organisation:

org.apache.ivy.plugins.matcher.MatcherHelper.matches(PatternMatcher, ModuleId, ModuleId)

Is this ‘[exclude]’ element in the ‘[dependencies]’ container element of ivy.xml, or nested inside a particular ‘[dependency]’ element?

This does look like it might be a bug. Once you confirm the above question I’ll raise in in Jira.

Would you be interested in helping out with a fix? This would involve: * creating some integration tests demonstrating the bug (infrastructure is already there) * fixing the actual bug, with consultation with Gradleware devs * submit a pull request with your changes

Supplying a fix is a pretty good way of expediting the resolution of this bug!

The ‘exclude’ element is inside a ‘dependencies’ element.

I would be glad to help with the fix.

I would be glad to help with the fix.

That would be great! Here’s a suggested way to get started.

  • Check out the development page to learn how to get started working on Gradle. * Fork the Gradle project on GitHub. * Add some more tests to ‘org.gradle.integtests.resolve.ivy.IvyResolveIntegrationTest’ for the ‘exclude’ element in ivy.xml

  • We use ‘org.gradle.test.fixtures.ivy.IvyFileModule’ to generate ivy projects for testing. You’ll need to add ‘exclude(Map<String, ?> options)’ and use this to add exclude elements to the generated ivy files.

  • Add test to demonstrate the correct application of the ‘exclude’ element with ‘module’ and ‘organisation’ attributes

  • Add test to demonstrate incorrect application of the ‘exclude’ element with ‘type’ and ‘conf’ attributes. * Investigate what needs to be done to fix the bug. If it’s straightforward, then just add the fix to your fork. If there are a number of ways to proceed, then raise the problem on the dev mailing list.

Again, thanks for offering to help. We rely on contributors like yourself to help make Gradle better!