How to fix pom.xml for a downloaded/resolved dependency?


(Marian Stránecký) #1

Hi,

I have a maven dependency on a library, which in turn has a transitive dependency.

Unfortunately, this transitive dependency has a corrupted pom.xml (http://central.maven.org/maven2/javax/jdo/jdo2-api/2.2/jdo2-api-2.2.pom):

<groupId>javax.jdo</groupId>
    <artifactId>jdo2-api</artifactId>
    <version>${currentVersion}</version>

This fails the build:

FAILURE: Build failed with an exception.

  • What went wrong:

Could not resolve all dependencies for configuration ‘:com.ysoft.safeq.module:core:compile’.

Could not resolve javax.jdo:jdo2-api:2.2.

Required by:

------------- some_internal:dependencyA -------------

inconsistent module metadata found. Descriptor: C:\storage.mvnrepo\javax\jdo\jdo2-api\2.2\jdo2-api-2.2.pom Errors: bad version: expected=‘2.2’ found=’${currentVersion}’

The question is if there is any patching mechanism I can use to solve this issue…

Thank you in advance for any hint, Marian


(uklance) #2

Perhaps you can make use of the “nearest definition wins” strategy.

If you explicitly define a version of javax.jdo:jdo2-api in your pom.xml or build.gradle it should take preference over the transitive version.


(Marian Stránecký) #3

IMHO this doesn’t solve the problem as the artifact’s pom.xml is still corrupt in such a case… (and there is no other public version I can use)

I know I can store fixed artifact in nexus/artifactory, but I was asking about a patching mechanism - e.g. using a locally stored pom.xml I can use for metadata…

Btw., I have tried to exclude this transitive depedency:

compile(“3rdparty:some-lib:$someLibVersion”) {

exclude group: ‘javax.jdo’

}

but despite the exclusion, it’s still processed by gradle and thus leading to the error…

16:58:46.447 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] javax.jdo#jdo2-api is excluded from 3rdparty:some-lib:3.2.6-SNAPSHOT(default).

16:58:50.838 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency 3rdparty:some-lib:3.2.6-SNAPSHOT(compile) -> javax.jdo:jdo2-api:2.2(dependency: javax.jdo#jdo2-api;2.2 {compile=[compile(), master()], runtime=[runtime(*)]})

16:58:50.838 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Selecting new module version javax.jdo:jdo2-api:2.2

16:58:50.838 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module ‘javax.jdo:jdo2-api:2.2’ using repositories [MavenLocal, MavenRepo, maven, maven2, maven3, maven4, maven5, maven6, maven7]

16:58:50.839 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading C:\storage.mvnrepo/javax/jdo/jdo2-api/2.2/jdo2-api-2.2.pom