Generated ivy.xml is incorrect for project with 'war' plugin applied

Given this Gradle file:

apply plugin: 'java'
apply plugin: 'war'

And assuming there is some code in src/main/webapps, when running ‘uploadArchives’ Gradle generates the following ivy.xml:

<ivy-module version="2.0" xmlns:m="">
 <info organisation=""
  <conf name="archives" visibility="public" description="Configuration for archive artifacts."/>
  <conf name="compile" visibility="private" description="Classpath for compiling the main sources." extends="providedCompile"/>
  <conf name="default" visibility="public" description="Configuration for default artifacts." extends="runtime"/>
  <conf name="providedCompile" visibility="private" description="Additional compile classpath for libraries that should not be part of the WAR archive."/>
  <conf name="providedRuntime" visibility="private" description="Additional runtime classpath for libraries that should not be part of the WAR archive." extends="providedCompile"/>
  <conf name="runtime" visibility="private" description="Classpath for running the compiled main classes." extends="compile,providedRuntime"/>
  <conf name="testCompile" visibility="private" description="Classpath for compiling the test sources." extends="compile"/>
  <conf name="testRuntime" visibility="private" description="Classpath for running the compiled test classes." extends="runtime,testCompile"/>
  <artifact name="gradleTestProj" type="war" ext="war" conf="archives"/>
  <artifact name="gradleTestProj" type="jar" ext="jar" conf="runtime"/>

As you can, see an artifact exists in the section that is never actually created. Worse, the war file is not part of the runtime configuration, so other projects that include this war as a dependency will be unable to locate the actual published artifact.

I need the ‘uploadArchives’ task to generate an ivy.xml file for the war much the same way it does for a jar. If I convert my project to a jar, it generates a publications sections like so:

  <artifact name="gradleTestProj" type="jar" ext="jar" conf="archives,runtime"/>

Is this behavior intended? Is there a workaround for it?

We’re aware of a number of issues with ivy.xml & pom.xml generation for ‘war’ projects. We’re currently working on new plugins for publication that will address these (and other) issues. Gradle 1.3 introduced the first iteration of this new ivy-publish plugin, that gives you the ability to modify the generated ivy.xml file before uploading.

You may be able to use this plugin to workaround the current limitations: in the future this plugin will “just work” for publishing web applications.

I’ve created GRADLE-2575 to track this particular issue.


Thanks. I was able to get that working by doing the following:

publishing {
  publications {
    ivy {
      descriptor {
        withXml {
          asNode().publications.artifact.find { it.@type == "war" }.@conf = "archives, runtime"