Is there a difference between Ivy resolving when using gradle and when using Ivy directly?

My question came up because i face a strange behaviour with some dependencies that we use in our projects where the resolving is done via IVY (Ant/Gant build) and that I’m migrating to a Gradle build.

Here my example dependency :

<dependency org="org.apache.xmlgraphics" name="fop" rev="0.94" conf="default->compile,master" />

Using Ivy directly ends up with

downloading https://company/repository/trunk/ivyrepo/org.apache.xmlgraphics/fop/0.94/fop-0.94.jar … so no problem.

Now when I use the same dependency in my gradle build using the same Ivy.jar ,repository etc… it ends up with

Caused by: java.lang.RuntimeException: Module version group:, module:PMOAM, version:1.0, configuration:testCompile declares a dependency on configuration 'default->compile,master' which is not declared in the module descriptor for group:org.apache.xmlgraphics, module:fop, version:0.94

Hey nelson, can you provide the gradle snippet where you declare the dependency in gradle?

cheers, René

Hi René,

here my snippet. I have a ivy.xml that contains the dependency above.

my example from my build.gradle (declaration and the method I use to test this)

dependencies {
  def ivyDependencies(conf) {
        def dep = []
    def ivyModule = new XmlParser().parse(file("ivyG.xml"))
         def configuration = ivyModule.dependencies.@defaultconf
    println "DEFAULT PROJECT CONFIGURATION -> $configuration"
          ivyModule.dependencies.dependency.each {
                 def defConf = conf == null ? it.@conf == null ? configuration[0]
: it.@conf
: conf
                              dep.add ([group: it.@org , name: it.@name ,
 version: it.@rev, configuration : defConf])
         return dep

The error you get indicates that something is wrong with your ivy file parsing. I guess you pass the following as configuration “default->compile,master” which is not a valid configuration name. can you try with just ‘default’ instead?

cheers, René

Yes I pass “default->compile,master” as the conf and was assuming that it’s handled in the same way Ivy would handle a configuration like this.

Configuration “Default” in this case of course works but my problem is that the number of jars that is resolved is not the same.

Another example - we have a company made artifact that is also resolving a zip file containing global web parts like jsps, js , css etc… As for now we publish the jar and zip and access if with conf=“default>web”

<dependency org="comp-org" name="comp-util" rev="3.0.7" conf="default->web"/>

After download we unpack it with ant

<ant-call target="globalResources" prefix="dep"
        event="post-retrieve-artifact" filter="type=web AND organisation=comp-org AND module=comp-util AND ext=zip AND artifact=comp-util_web"/>

In this case I face a similar problem telling me there is nos such a configuration and I must specify the dependency twice one time with conf=“default” and one time with conf=“web”

I wonder why its does not behave the same when the Ivy resolving mechanism is used here or am I not correct in my thoughts ?

Regards Nelson

Gradle supports Ivy repositories, but doesn’t support all Ivy concepts and notations. Gradle implements its own dependency management solution and isn’t using Ivy under the hood anymore (with some small exceptions).

Am I right in that you are simply looking for a way to specify multiple configurations at once? If yes, that would make a good feature request.

Thank you for the explanation Peter and yes that’s exactly what I am looking for.

After reading the source of DependencyGraphBuilder it became clearer to me what happens under the hood.

Regards Nelson