Ivy support uses non-standard ivy layout pattern

Gradle’s ivy-publish plugin uses a non-standard ivy layout pattern. I found a mailing list post where this feature was implemented and the developer asked if anyone knew if there was a standard layout. They weren’t sure what the default ivy layout was and so used the maven layout. However, there is indeed a default ivy layout and it is different than the Maven layout. The fact that Gradle does not properly implement this makes it very difficult to interoperate with other tools. I was able to fix it by specificying the layout as shown below. I would love to see Gradle’s non-standard default be updated to the standard layout so that it will work with other tools.

publishing {
      publications {
        ivyJava(IvyPublication) {
          from components.java
        }
      }
      repositories {
        ivy {
          url "${System.properties['user.home']}/.ivy2/local"
          layout 'pattern', {
            artifact '[organisation]/[module]/[revision]/[ext]s/[artifact](.[ext])'
            ivy '[organisation]/[module]/[revision]/[artifact]/[artifact](.[ext])'
          }
        }
      }
    }

You can see this is what is defined in ivysettings-local.xml except ivy has a [type] which gradle does not support so I had to replace it with [ext] and [artifact] in order to get the same result.

<property name="ivy.local.default.ivy.pattern"
    value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
    <property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>

Opened a pull request for the fix: https://github.com/gradle/gradle/pull/265

Which “other tools” are you referring to? Just curious.

Most of our libraries are built with Gradle. The exception is our Play Framework project since Play forces you to use SBT at the moment unless Gradle implements support for it. SBT uses ~/.ivy2 so we’d like to publish our libraries built with Gradle there so that our web app can use them, but that requires Play to publish the libraries using the correct directory structure. I haven’t tested with the official Ant Ivy plugin yet, but I looked at the source code (see the reference to ivysettings-local.xml above) and it’s clear that SBT implemented ivy support using the official Ivy layout. I’d have to imagine any other tools using ivy would expect the same directory structure.