MVN issue with an old Java codebase -- clashing dependencies

368 Views Asked by At

I have an old Java codebase (1.7). I'm trying to get it to run on a newer version of the JVM, and in general I got it to compile. What I can solve is the part in the build process that uses wro4j. Maven gives me this error:

Plugin ro.isdc.wro4j:wro4j-maven-plugin:1.10.1 or one of its dependencies could not be resolved:
Failed to collect dependencies for ro.isdc.wro4j:wro4j-maven-plugin:jar:1.10.1 ():
Could not resolve version conflict among 
[ro.isdc.wro4j:wro4j-maven-plugin:jar:1.10.1 -> ro.isdc.wro4j:wro4j-extensions:jar:1.10.1 -> org.webjars.npm:jshint:jar:2.11.0 -> org.webjars.npm:minimatch:jar:[3.0.2,3.1), 
ro.isdc.wro4j:wro4j-maven-plugin:jar:1.10.1 -> ro.isdc.wro4j:wro4j-extensions:jar:1.10.1 -> org.webjars.npm:jshint:jar:2.11.0 -> org.webjars.npm:cli:jar:[1.0.0,1.1) -> org.webjars.npm:glob:jar:[7.1.1,8) -> org.webjars.npm:minimatch:jar:[3.1.1,4)

Both dependencies chains end with minimatch -- one needs [3.1.1,4], the other [3.0.2,3.1]. I have a feeling that whatever works with 3.1 will work with 3.1.1, but I have no idea how to "force" (or trick?) MVN to allow that.

This is the part in the POM file that uses wro4j:

      <plugin>
        <groupId>ro.isdc.wro4j</groupId>
        <artifactId>wro4j-maven-plugin</artifactId>
        <version>1.10.1</version>
          <executions>
              <execution>
                  <phase>compile</phase>
                  <goals>
                      <goal>run</goal>
                  </goals>
              </execution>
          </executions>
          <configuration>
              <minimize>true</minimize>
              <wroFile>${basedir}/src/main/resources/wro.xml</wroFile>
              <contextFolder>${basedir}/WebContent/</contextFolder>
              <destinationFolder>${basedir}/WebContent/js/compiled</destinationFolder>
          </configuration>
      </plugin>

wro4j is not declared as a dependency anywhere else in the POM file. Same goes for the entire dependencies chain in the error message. The issue is this:

org.webjars.npm:cli:jar:[1.0.0,1.1) -> org.webjars.npm:glob:jar:[7.1.1,8) -> org.webjars.npm:minimatch:jar:[3.1.1,4)

org.webjars.npm:jshint requires both minimatch [3.0.2,3.1], and also org.webjars.npm:cli: - which in turn has an indirect dependency on minimatch [3.1,4]

Any ideas?

1

There are 1 best solutions below

0
On

I love how just asking a question clears your head enough to figure it out! Here's I solved it:

  1. Understood what I'm looking for is a way to override dependencies for a plugin
  2. Found this: How to override a plugin's dependency in Maven
  3. Checked the dependencies path and found that if I force org.webjars.npm.glob to use 7.1.1, things will work out.
  4. Added this to the <plugin> element loading wro4j:
<dependencies>
    <dependency>
        <groupId>org.webjars.npm</groupId>
        <artifactId>glob</artifactId>
        <version>7.1.1</version>
    </dependency>
</dependencies>      

and voila!