Gradle 1.10 breaks with POM files that reference properties from the parent pom


(Phil Messenger) #1

It seems that Gradle 1.10 has problems with POM files which reference properties set in the parent POM. The one that’s causing us trouble at the moment is this one, which contains the following dependency:

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>${hadoop.common.artifact.id}</artifactId>
<optional>true</optional>
</dependency>

Note the variable substitution for the artifact id. This breaks in Gradle 1.10, but not in Gradle 1.9 with the following error:

Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.UnresolvedDependencyVersionException: Unable to resolve version for dependency 'org.apache.hadoop:${hadoop.common.artifact.id}:jar'

For now we can use Gradle 1.9, but I’m sure this problem will hit someone else.


(Benjamin Muschko) #2

With Gradle 1.10 we actually fail POM parsing if a version of a dependency cannot be resolved. In your given example the property ‘hadoop.common.artifact.id’ is not declared in the parent POM. It is a property defined in a profile of the dependency ‘org.apache.flume.flume-ng-sinks:flume-hdfs-sink:1.3.1’. Maven highly discourages to use of profiles in published POMs. We are not actually evaluating profiles. So generally speaking the version cannot be resolved. This has been discussed on the Gradle forum before. Have a look at this posting for example.

Given that the dependency has the scope ‘optional’ we might want to check for that. Maven’s documentation says that such dependencies are “excluded by default.” You can also see that with 1.9 the Hadoop dependency is not part of your dependency graph (try running ‘gradle dependencies’).