Transitive dependencies in ear lib dir in multi project builds

I have the following multi project setup:

earProject (ear) ----projectA (java) --------dependency1 --------dependency2

the earProject has the ear plugin applied, and should produce a .ear file. ProjectA is a java project producing a .jar.

Now, when I try to include projectA in my ear I run into issues with my transitive dependencies:

dependencies {

deploy project(":projectA") } // projectA in root of ear, but no libs deployed, dependency1 & dependency2 missing in lib/

dependencies {

deploy project(":projectA")

earlib project(":projectA") } // dependency1 & dependency2 now in lib/ - but projectA.jar deployed in both root and lib/

How do I deploy projectA.jar in the root, but all its dependencies (which are not in the deploy configuration) in lib/ ? Currently I have a very dirty hack that iterates the dependencies of the earlib configuration to look for all that are not in the deploy configuration, but this seems wrong. Am I missing something, or isn’t this something a lot of multi-project builds would run into? Is there some correct way of handling this issues that I am simply not seeing?

It seems this is a limitation in the ‘ear plugin’ according to the documentation.

You might be able to work around this by referencing a specific ‘configuration’ of the project for the ‘earlib’ configuration. See http://forums.gradle.org/gradle/topics/problem_with_the_ear_plugin for details on how you might do this.