Gradle 2.3: ivy configuration mapping makes dependencies resolution to fail (*,!test)

Hello,

I upgraded somes projects from gradle 1.11 to gradle 2.3 and faces an issue with some ivy dependencies whose ivy.xml contains the following configuration :

<ivy-module version="2.0">
<info .../>
<configurations defaultconfmapping="test->*;default->*,!test;%->*,!test">
  <conf name="test" extends="default"/>
  <conf name="default"/>
</configurations>
...
<dependencies>
    <dependency org="log4j" name="log4j" rev="1.2.14"/>
    ...

If fails during resolution of a log4j dependency with the following error:

15:42:59.420 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency xxx:yyy:5.63.0(default) -> log4j:log4j:1.2.14(dependency: log4j#log4j;1.2.14 {test=[*], default=[*, !test], %=[*, !test]})
15:42:59.420 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version log4j:log4j:1.2.14
...
15:42:59.439 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.IvyXmlModuleDescriptorParser] post 1.3 ivy file: using exact as default matcher
15:42:59.440 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'log4j:log4j:1.2.14' in 'maven'
15:42:59.450 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Using log4j:log4j:1.2.14 from Maven repository 'maven'
...
  > Module version xxx:yyy:5.63.0, configuration 'default' declares a dependency on configuration '*!test' which is not declared in the module descriptor for log4j:log4j:1.2.14

I do not understand from where comes the *!test configuration. I unfortunately do no have a public accessible ivy repository where such module is published.

Is there something i can do to fix this without touching to the xxx:yyy module’s ivy.xml in my gradle configuration ? Or the ivy.xml configuration is definitively wrong ?

I created a self contained project reproducing the problem on github project https://github.com/Starch/test-ivy

~/dev $ git clone https://github.com/Starch/test-ivy
~/dev $ cd test-ivy/project/
~/dev/test-ivy/project[master] $ ./gradlew test
:compileJava
  FAILURE: Build failed with an exception.
  * What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Module version xxx:yyy:5.63.0, configuration 'default' declares a dependency on configuration '*!test' which is not declared in the module descriptor for net.sourceforge.cobertura:cobertura:1.9
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED
  Total time: 4.521 secs

I know you said you were migrating from 1.11, but it actually looks like the last version that works for me with your example project is Gradle 1.6. I get the failure you reported with Gradle 1.7 and above. I’ve created https://issues.gradle.org/browse/GRADLE-3244 to track this issue.

Thanks for the ticket !

I investigated on why my real project did work with 1.11, while the example project did not.

It seems that the original ivy file had some exclude rules that make gradle-1.11 to not fail. But it did not work either, as transitive dependencies were not properly resolved (and I had to add them manually). It is probably the fix of GRADLE-2674 that triggered my project failure using gradle 2.3.

I updated my test project with those exclude rules, if it can help.