3

During build via Gradle I got this

POM relocation to an other version number is not fully supported in Gradle : xml-apis:xml-apis:2.0.2 relocated to xml-apis:x
ml-apis:1.0.b2.
Please update your dependency to directly use the correct version 'xml-apis:xml-apis:1.0.b2'.
Resolution will only pick dependencies of the relocated element. Artifacts and other metadata will be ignored.

Batik 1.7 was used in project. This version of Batik uses Xalan 2.6.0, which has dependency on xml-apis 2.0.2, which was relocated.

How to resolve this transitive dependency?

m_Z
  • 41
  • 1
  • 1
  • 2

1 Answers1

8

Option 1:

configurations.all {
    resolutionStrategy {
        force 'xml-apis:xml-apis:1.0.b2'
    }
}

See ResolutionStrategy.force(...)

Option 2:

dependencies {
    compile "batik:batik:$batikVersion", {
       exclude group: "xml-apis", module: "xml-apis"
    }
    compile "xml-apis:xml-apis:1.0.b2"
}

See ModuleDependency.exclude(Map)

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • In your option 2, you are excluding a specific version and including the version which is needed. My doubt is that, in this case 'x' jar uses 'y' jar so exclude and include our wanted version. But let's say 'x' jar uses 'y' jar which again used 'z' jar, then what should I do if I want specific version of 'z' jar? – Aravinth Jun 29 '19 at 18:44
  • 1
    "In your option 2, you are excluding a specific version" That's incorrect. I'm not specifying a version. So it excludes all versions (regardless of x/y or x/y/z scenario). So then I can explicitly choose the version I want, knowing its not included by batik (or any of batik's transitive dependencies) – lance-java Jun 29 '19 at 22:43