Transitive Dependencies: Connecting Two Projects

(my accounts) #1


  1. I have two projects: A and B.

  2. Project A depends on ZeroMQ jar ( and many other jars, but let’s take one as an example )

  3. Project A is built, uploadArchives to nexus repo as a snapshot ( projectA-0.0.1.BUILD-SNAPSHOT )

  4. Project B depends on project A as a JAR => “projectA-0.0.1.BUILD-SNAPSHOT.jar”

  5. Project B is runnable, hence it’d need all the A’s dependencies to run succesfully

How do I make Project B pull all the A’s dependencies?

Things I tried in Project B:

allprojects {
   configurations.all {
 transitive = true
runtime( '' ) { transitive = true }

and many other things.

Thank you!

In general ( as a side feedback ): it would be a lot easier to have a short and concise summary of all the “most/frequently used” options / Gradle variables, as oppose to have it spread out over the long guide. But that is besides the point.

(Peter Niederwieser) #2

How do I make Project B pull all the A’s dependencies?

What exactly do you mean by that? If you declare a dependency on A, you will automatically get A’s dependencies as well. Try:

dependencies {
  compile ''
  task printDeps << {
  configurations.compile.each { println it }

(my accounts) #3


That was my understanding too. But all I get is:

$ gradle printDeps
  Total time: 8.252 secs

While in nexus repo, where project B is pulling project A from, I can look at project’s A POM and see many dependencies.

What is interesting, once the project A gets pulled into Gradle cache, I can’t see any of its dependencies in ivy.xml:

$ cat ~/.gradle/cache/
 <?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
 <info organisation=""
  <conf name="default" visibility="public"/>
  <artifact name="projectA" type="jar" ext="jar" conf="default"/>

(Peter Niederwieser) #4

My guess is that for some reason, project A’s pom.xml isn’t found and a default ivy.xml created. What does your ‘repositories’ section look like?

(my accounts) #5

for project B? Here it is:

repositories {
    mavenRepo urls: ["",

(Peter Niederwieser) #6

Passing multiple URLs to ‘mavenRepo’ has a very special meaning. (It’s a common pitfall, and that’s why we have changed the DSL in milestone-5). Change it to:

repositories {
    mavenRepo urls: ""
    mavenRepo urls: "http://host/nexus/content/groups/public/"
    mavenRepo urls: "http://host/nexus/content/repositories/snapshots/"
    mavenRepo urls: ""
    mavenRepo urls: ""
    mavenRepo urls: ""

This will very likely solve the problem.

(my accounts) #7

hm… so it seems that with a repository list a POM is only looked up in the first repository entry. I see… well that was not so obvious :slight_smile:

Thanks Peter!

(my accounts) #8

sugar was updated in M7 ( in case someone else has the problem ):

repositories {


maven { url ‘’ }

maven { url ‘’ }

maven { url ‘’ }

maven { url ‘’ } }