Gradle does not include transitive required compile dependency

I’m using Gradle 1.6. Here is the project that I have:

apply plugin: 'groovy'
repositories { mavenCentral() }
dependencies {
compile 'org.apache.activemq:activemq-core:5.4.0' }

org.apache.activemq:activemq-core:5.4.0 has a compile dependency on activeio-core (http://search.maven.org/remotecontent?filepath=org/apache/activemq/activemq-core/5.4.0/activemq-core-5.4.0.pom):

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>activeio-core</artifactId>
  <optional>false</optional>
</dependency>

The dependency is actually defined in here: http://search.maven.org/remotecontent?filepath=org/apache/activemq/activemq-parent/5.4.0/activemq-parent-5.4.0.pom.

Gradle doesn’t resolve the dependency:

$ ./gradlew dependencyInsight --dependency activeio-core
:dependencyInsight
No dependencies matching given input were found in configuration ':compile'
  $ ./gradlew dependencies --configuration compile
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
compile - Compile classpath for source set 'main'.
\--- org.apache.activemq:activemq-core:5.4.0
     +--- commons-logging:commons-logging-api:1.1
     +--- org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1
     +--- org.apache.activemq:kahadb:5.4.0
     |
  \--- commons-logging:commons-logging:1.1 -> 1.1.1
     +--- org.apache.activemq.protobuf:activemq-protobuf:1.1
     +--- org.osgi:org.osgi.core:4.1.0
     +--- org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:1.0.1
     +--- org.springframework:spring-context:3.0.3.RELEASE
     |
  +--- org.springframework:spring-aop:3.0.3.RELEASE
     |
  |
  +--- aopalliance:aopalliance:1.0
     |
  |
  +--- org.springframework:spring-asm:3.0.3.RELEASE
     |
  |
  +--- org.springframework:spring-beans:3.0.3.RELEASE
     |
  |
  |
  \--- org.springframework:spring-core:3.0.3.RELEASE
     |
  |
  |
       +--- org.springframework:spring-asm:3.0.3.RELEASE
     |
  |
  |
       \--- commons-logging:commons-logging:1.1.1
     |
  |
  \--- org.springframework:spring-core:3.0.3.RELEASE (*)
     |
  +--- org.springframework:spring-beans:3.0.3.RELEASE (*)
     |
  +--- org.springframework:spring-core:3.0.3.RELEASE (*)
     |
  +--- org.springframework:spring-expression:3.0.3.RELEASE
     |
  |
  \--- org.springframework:spring-core:3.0.3.RELEASE (*)
     |
  \--- org.springframework:spring-asm:3.0.3.RELEASE
     \--- commons-net:commons-net:2.0
  $ ./gradlew dependencies | grep -i activeio-core
$ echo $?
1

(The last two lines just show that grepping all dependencies for activeio-core finds nothing.)

Can it be that Gradle gets confused with the second dependency:

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>activeio-core</artifactId>
  <optional>false</optional>
  <type>test-jar</type>
</dependency>

Analogous maven project:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>de.test</groupId>
  <artifactId>maven-deps</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-core</artifactId>
      <version>5.4.0</version>
    </dependency>
  </dependencies>
</project>

produces this:

$ mvn dependency:tree -Dverbose
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-deps 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ maven-deps ---
[INFO] de.test:maven-deps:jar:1.0-SNAPSHOT
[INFO] \- org.apache.activemq:activemq-core:jar:5.4.0:compile
[INFO]
  +- commons-logging:commons-logging-api:jar:1.1:compile
[INFO]
  +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
[INFO]
  +- org.apache.activemq:activeio-core:jar:3.1.2:compile
[INFO]
  |
+- (org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:compile - omitted for duplicate)
[INFO]
  |
\- commons-logging:commons-logging:jar:1.1:compile
[INFO]
  |
   +- log4j:log4j:jar:1.2.12:compile
[INFO]
  |
   +- logkit:logkit:jar:1.0.1:compile
[INFO]
  |
   +- avalon-framework:avalon-framework:jar:4.1.3:compile
[INFO]
  |
   \- javax.servlet:servlet-api:jar:2.3:compile
[INFO]
  +- org.apache.activemq:kahadb:jar:5.4.0:compile
[INFO]
  |
\- (commons-logging:commons-logging:jar:1.1:compile - omitted for duplicate)
[INFO]
  +- org.apache.activemq.protobuf:activemq-protobuf:jar:1.1:compile
[INFO]
  +- org.osgi:org.osgi.core:jar:4.1.0:compile
[INFO]
  +- org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:compile
[INFO]
  +- org.springframework:spring-context:jar:3.0.3.RELEASE:compile
[INFO]
  |
+- org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
[INFO]
  |
|
+- aopalliance:aopalliance:jar:1.0:compile
[INFO]
  |
|
+- (org.springframework:spring-asm:jar:3.0.3.RELEASE:compile - omitted for duplicate)
[INFO]
  |
|
+- (org.springframework:spring-beans:jar:3.0.3.RELEASE:compile - omitted for duplicate)
[INFO]
  |
|
\- (org.springframework:spring-core:jar:3.0.3.RELEASE:compile - omitted for duplicate)
[INFO]
  |
+- org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
[INFO]
  |
|
\- (org.springframework:spring-core:jar:3.0.3.RELEASE:compile - omitted for duplicate)
[INFO]
  |
+- org.springframework:spring-core:jar:3.0.3.RELEASE:compile
[INFO]
  |
|
+- (org.springframework:spring-asm:jar:3.0.3.RELEASE:compile - omitted for duplicate)
[INFO]
  |
|
\- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
[INFO]
  |
+- org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
[INFO]
  |
|
\- (org.springframework:spring-core:jar:3.0.3.RELEASE:compile - omitted for duplicate)
[INFO]
  |
\- org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
[INFO]
  \- commons-net:commons-net:jar:2.0:compile

As you can see, the org.apache.activemq:activeio-core:jar:3.1.2:compile dependency is there. It is not only a problem of the dependency plugin, as my originla issue comes from a webapp, and WEB-INF/lib by Gradle doesn’t contain the lib, and maven’s does.

wujek

A very similar problem occurs with the following:

apply plugin: 'groovy'
repositories { mavenCentral() }
dependencies { compile 'org.apache.myfaces.core:myfaces-impl:2.1.9' }

org.apache.myfaces:myfaces-impl:2.1.9 has a compile dependency on myfaces-api (http://search.maven.org/remotecontent?filepath=org/apache/myfaces/core/myfaces-impl/2.1.9/myfaces-impl-2.1.9.pom):

<dependency>
  <groupId>org.apache.myfaces.core</groupId>
  <artifactId>myfaces-api</artifactId>
</dependency>

The dependency is actually defined in here: http://search.maven.org/remotecontent?filepath=org/apache/myfaces/core/myfaces-core-project/2.1.9/myfaces-core-project-2.1.9.pom.

Gradle doesn’t resolve the dependency:

$ ./gradlew dependencyInsight --dependency myfaces-api
:dependencyInsight
No dependencies matching given input were found in configuration ':compile'
  $ ./gradlew dependencies --configuration compile
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
compile - Compile classpath for source set 'main'.
\--- org.apache.myfaces.core:myfaces-impl:2.1.9
     +--- commons-collections:commons-collections:3.2
     +--- commons-codec:commons-codec:1.3
     +--- commons-beanutils:commons-beanutils:1.8.3
     |
  \--- commons-logging:commons-logging:1.1.1
     \--- commons-digester:commons-digester:1.8
          +--- commons-beanutils:commons-beanutils:1.7.0 -> 1.8.3 (*)
          \--- commons-logging:commons-logging:1.1 -> 1.1.1
  $ ./gradlew dependencies | grep -i myfaces-api
$ echo $?
1

(The last two lines just show that grepping all dependencies for activeio-core finds nothing.)

An similar situation as before, there is another dependency (also in the parent):

<dependency>
  <groupId>org.apache.myfaces.core</groupId>
  <artifactId>myfaces-api</artifactId>
  <classifier>tests</classifier>
  <scope>test</scope>
</dependency>

Analogous maven project:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>de.test</groupId>
  <artifactId>maven-deps</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-impl</artifactId>
      <version>2.1.9</version>
    </dependency>
  </dependencies>
</project>

produces this:

$ mvn dependency:tree -Dverbose
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-deps 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ maven-deps ---
[INFO] de.test:maven-deps:jar:1.0-SNAPSHOT
[INFO] \- org.apache.myfaces.core:myfaces-impl:jar:2.1.9:compile
[INFO]
  +- org.apache.myfaces.core:myfaces-api:jar:2.1.9:compile
[INFO]
  +- commons-collections:commons-collections:jar:3.2:compile
[INFO]
  +- commons-codec:commons-codec:jar:1.3:compile
[INFO]
  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO]
  |
\- commons-logging:commons-logging:jar:1.1.1:compile
[INFO]
  \- commons-digester:commons-digester:jar:1.8:compile
[INFO]
     +- (commons-beanutils:commons-beanutils:jar:1.7.0:compile - omitted for conflict with 1.8.3)
[INFO]
     \- (commons-logging:commons-logging:jar:1.1:compile - omitted for conflict with 1.1.1)

As you can see, the myfaces-api dependency is in the list.

wujek

Looks like a problem related to Gradle’s handling of the ‘classifier’ and ‘type’ elements. I’ve raised GRADLE-2796.