Ivy artifact pattern seems to swap the artifact and module items


I have this ivy.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/ivy/xsl/ivy-doc.xsl"?>
  <ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:noNamespaceSchemaLocation="http:/myorg/ivy/xsd/ivy.xsd">
 <info organisation="myorg.campaign" module="schema" branch="development" revision="3.0dev2" status="integration" publication="20150126144431"/>
  <conf name="compile"/>
  <conf name="runtime" extends="compile"/>
  <conf name="test" extends="runtime"/>
  <conf name="default" extends="runtime"/>
  <artifact name="campaign-schema" type="jar" ext="jar" conf="runtime"/>
  <dependency org="myorg.common" name="dbinit" rev="1.0dev12" branchConstraint="development" revConstraint="1.0+" branch="development" conf="test->test;runtime->runtime"/>
  <exclude ext="zip"/>

My build.gradle defines the dependency like this:

compile ('myorg.campaign:schema:3.0+:runtime')

My repository is defined as:

repositories {
    //Ivy repository for myorg projects
        url "http://" + project."config.ivy.remote.host" +"/ivy/myorg"
        layout 'pattern' , {
               artifact "[organisation]/[module]/development/[revision]/[artifact].[ext]"
               ivy "[organisation]/[module]/development/ivys/ivy-[revision].xml"

Now, Gradle errors out with:

16:20:44.679 [ERROR] [org.gradle.BuildExceptionReporter]
 Searched in the following locations:
16:20:44.679 [ERROR] [org.gradle.BuildExceptionReporter]

It looks like it used the [module] name instead of the [artifact] name in the pattern. it should have looked for


This seems to be broken in 2.1 forward (haven’t checked older builds) and at least this nightly (gradle-2.4-20150216230039+0000)

Thanks, Marc

Hi Marc. Sorry for the delay getting back to you.

Can you confirm that the ‘ivy’ file is found at:


I’m thinking that perhaps you’re seeing the behaviour where Gradle will look for a Jar file in a default location if no ‘ivy.xml’ file is found. It’s possible that we don’t honour the artifact name in this case.

Then again, it could be a more general bug that you’ve exposed.

Thanks Daz,

Yes, I am sure it finds the ivy.xml since it grabs the dependencies (as of 2.3), but while I was verifying this, I found another interesting tidbit.

It seems to work if I don’t specify the ‘configuration’ on this line… in this particular case, since default extends runtime, it works as expected.

compile ('myorg.campaign:schema:3.0+:runtime')

I was trying to get the gradle code to run in eclipse so I could debug it, but got busy with work items. If time allows, I’ll try to get a small reproducible case laid out.


Thanks. A reproducible test case would really help isolate a fix.

Hi Daz,

You can clone a repo that shows the situation from here: https://github.com/mrawji/gradle-artifactVsModules

The (very) simple build.gradle has a comment in it, showing how to reproduce the situation (just swap the dependency line).

Everything “self contained” in the repo. The keep things simple, the jar is minuscule and invalid, so compilation will throw an warning, but that’s fine.

When it works, you’ll get this:

mrawji@NA-1309-036:~/artifactVsModules$ gradle compileJava
error: error reading /home/mrawji/artifactVsModules/ivyrepo/myorg/schema/development/3.0dev2/campaign-schema.jar; error in opening zip file
warning: [options] bootstrap class path not set in conjunction with -source 1.6
error: error reading /home/mrawji/artifactVsModules/ivyrepo/myorg/schema/development/3.0dev2/campaign-schema.jar; error in opening zip file
1 warning
  Total time: 2.817 secs

and, in the error case

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not find schema-runtime.jar (myorg:schema:3.0dev2).
  Searched in the following locations:

gradle compileJava should be all you need…

Let me know if this helps. Marc

Thanks for the report, it took me a while to work out what was going on.

The problem is that the ‘:runtime’ part of

compile ('myorg.campaign:schema:3.0+:runtime')

is actually specifying the classifier for the dependency, not the configuration.

By definition, if you’re telling Gradle the classifier (or extension) for a dependency, you’re overriding the artifacts that would be retrieved by default. So instead of looking for the artifact that is defined in the ivy.xml file, Gradle is looking for an artifact called ‘{module-name}-runtime.jar’.

Hope that helps to clarify what’s going on.

Oy. Thanks Daz. I read that a super long time ago, and then forgot, since it “just worked”.

Making the change to

compile group: 'myorg', name: 'schema', version: '3.0+', configuration: 'runtime'

makes it work as expected.

For anyone else reading this: You must use the map notation, and the docs are here: https://gradle.org/docs/current/userguide/dependency_management.html#sec:dependency_configurations

Sorry for the wild goose chase. Marc