[GRADLE-2371] Scope mappings from POM dependency management do not consider type attribute Created: 05/Jul/12  Updated: 10/Nov/13  Resolved: 10/Nov/13

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.10-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0


This gist has 4 files: [1]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?


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] https://gist.github.com/3052189

Comment by Gradle Forums [ 05/Jul/12 ]

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 [1]activemq-parent pom, which contains:


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 [2]Client Module dependency declaration, such as:

dependencies {
compile module('org.apache.activemq:activemq-camel:5.6.0') {

[1] http://search.maven.org/#artifactdetails%7Corg.apache.activemq%7Cactivemq-parent%7C5.6.0%7Cpom
[2] http://gradle.org/docs/current/userguide/userguide_single.html#sub:client_module_dependencies

Generated at Wed Jun 30 12:20:05 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.