Why is generated POM missing a dependency listed in "gradle dependencies" compile group?

Using gradle 1.5, the dependency configuration below omits to generate dependencies for the “gwt” configuration in the generated POM file even though the “gradle dependencies” command shows the “gwt” dependencies in the “compile” group.

dependencies {
 compile project(':subproject-core')
 // ----------------------------------------------------
 // GWT dependencies
 // ----------------------------------------------------
 gwt group:'com.google.gwt', name:'gwt-user', version:GWT_VERSION
 gwt group:'com.sencha.gxt',name:'gxt',version:GXT_VERSION
          // apparently the line below is not the same as declaring the dependencies in the compile group directly
 compile configurations.gwt
// don't duplicate the GWT dependencies again
    // now the GWT emulation source (only needed for cross compiling from java to javascript)
 gwt group:'commons-lang',
                    name:'commons-lang-gwt',
          version:'2.4.0', classifier:'sources'
   // ----------------------------------------------------
 // Compile
  // ----------------------------------------------------
 compile ...other dependencies here
}

However the dependency configuration below works and the generated POM contains the expected dependencies

dependencies {
 compile project(':subproject-core')
 // ----------------------------------------------------
 // GWT dependencies
 // ----------------------------------------------------
 compile group:'com.google.gwt', name:'gwt-user', version:GWT_VERSION
 compile group:'com.sencha.gxt',name:'gxt',version:GXT_VERSION
   compile ...other dependencies here
   // now the GWT emulation source (only needed for cross compiling from java to javascript)
 gwt group:'commons-lang',
                    name:'commons-lang-gwt',
          version:'2.4.0', classifier:'sources'
  }

This may get around the missing dependency from the generated POM issue, but I still need a group with all my client side dependencies to do a gwt compile with, namely the “gwt” group and I don’t want to list the same dependencies twice.

Can you explain why I can’t use

compile configurations.gwt

to do a bulk add of dependencies into the compile group?

Can you explain why I can’t use ‘compile configurations.gwt’ to do a bulk add of dependencies into the compile group?

Adding a dependency on a configuration effectively creates a file dependency. This means that you are depending on the anonymous files that would be resolved, not the dependency definitions.

You don’t see this in the dependencies report because of GRADLE-2269.

The correct thing to do is to make the ‘compile’ configuration extend the ‘gwt’ one.

configurations {
  compile.extendsFrom gwt
}

To get these dependencies to display in the POM properly, you need to add the following to your build script:

conf2ScopeMappings.addMapping(1, configurations.gwt, "compile")

This is all nowhere near as elegant as we would like. The work we are doing on the new publication model will make some of this easier.

There’s a little documentation on this at: http://www.gradle.org/docs/current/userguide/maven_plugin.html#sub:dependency_mapping

Just to clarify, the dependency report for both of the above dependency techniques is EXACTLY the same, so adding the gwt dependencies to the compile group using

compile configurations.gwt

makes NO difference in the dependency report.

So I have successfully re-organised the build script to achieve my goals as follows

configurations {
 gwt
    // GWT client side JVM dependencies
 gwtcc.extendsFrom gwt // needed by GWT cross compiler
 compile.extendsFrom gwt
    ...
}
conf2ScopeMappings.addMapping(1, configurations.gwt, "compile")
...
dependencies {
 compile project(':subproject-core')
   // GWT dependencies
 gwt group:'com.google.gwt', name:'gwt-user',version:GWT_VERSION
   // GWT emulation package dependencies
 gwtcc group:'commons-lang',name:'commons-lang-gwt', version:'2.4.0', classifier:'sources'
   // Compile
  compile group:'commons-lang', name:'commons-lang', version:'2.4'
        ....
}

This ensures I have a group, named “gwtcc”, in which I can pass to the GWT cross compiler.

Many thanks for your help.