Scope mappings from POM dependency management do not consider type attribute

This gist has 4 files: https://gist.github.com/3052189

* a pom.xml with one dependency (activemq-camel)
* a gradle build file with maven+java plugins, and the same dependency
* output of `gradle dependencies`
* output of `mvn dependency:tree`

Why are the outputs not equal? The gradle dependencies are missing a lot of transitive dependencies, like activemq-core, which is a transitive compile scoped dependency.

In fact, it seems like Gradle only "follows" the two first top-level dependencies for their transitive dependencies (slf4j-api and camel-jms). What about the rest?

Environment:

Gradle 1.0
Gradle build time: Tuesday, June 12, 2012 12:56:21 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_33 (Apple Inc. 20.8-b03-424)
OS: Mac OS X 10.6.8 x86_64

Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
1 person has
this problem
+1
Reply
  • Daz DeBoer (Gradleware Engineer) July 05, 2012 16:09
    You have indeed exposed a bug in our handling of Maven pom files: Ivy 2.0 has reverse engineered the pom parsing logic and we are currently using a slightly modified version this code. We have plans to try to switch to using Maven code directly for pom parsing, but it's not trivial to integrate.

    The crux of the issue is the dependency management block in the activemq-parent pom, which contains:

    <dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-core</artifactId>
    <version>${activemq-version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-core</artifactId>
    <version>${activemq-version}</version>
    <type>test-jar</type>
    <scope>test</scope>
    </dependency>


    Unfortunately, we don't differentiate based on the `type` attribute, and the second entry overwrites the first, causing `activemq-core` to be mapped to the `test` scope. This explains why `activemq-core` and it's transitive dependencies are not part of the compile configuration.

    For now, the workaround for this issue is to use a Client Module dependency declaration, such as:


    dependencies {
    compile module('org.apache.activemq:activemq-camel:5.6.0') {
    dependency('org.slf4j:slf4j-api:1.6.4')
    dependency('org.apache.camel:camel-jms:2.9.2')
    dependency('org.apache.activemq:activemq-core:5.6.0')
    }
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated happy, confident, thankful, excited

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned