christopher oates
christopher oates

Reputation: 11

Why does Maven download hundreds of versions of maven-metadata.xml for dependency when I explicitly stated a non-snapshot version in pom.xml?

At my company we're upgrading to a new version of Scala but when I run mvn clean install, near the end of the build, it spends 22 minutes (!) trying to download metadata about these 3rd party dependencies from our company's Nexus (all the Cats libraries: cats-core, cats-macros, etc.). This dep, nor any of our 3rd party deps are "SNAPSHOT" version. Using mvn dependency:tree -Dverbose I can see some transitive dependencies have a version range [2,3) but in our pom.xml file we explicitly set the version as 2.0.0 and do not have the word "SNAPSHOT", as shown:

<dependency><groupId>org.typelevel</groupId><artifactId>cats-core_2.13</artifactId><version>2.0.0</version></dependency>

And yet during the build it tries to download hundreds of these versions between 2 and 3.

Why on earth is it doing it? What even are these SNAPSHOT versions? They don't seem to exist in Maven Central as far as I know. Nothing in our repo or any of the parent/child pom.xml files uses the word SNAPSHOT

screenshot of what I see in Nexus

screenshot of mvn build output

Upvotes: 0

Views: 73

Answers (1)

christopher oates
christopher oates

Reputation: 11

Alright, a coworker of mine eventually figured out the issue.

In our pom.xml we use the Ant plugin maven-antrun-plugin (we have some old JSP code that needs to be compiled with Ant). It appears the Ant plugin doesn't respect the version we declared. We have a transitive dependency that requires a range for Cats [2,3). That, in and of itself isn't a problem: in all other parts of the code that transitive dependency instantly resolves to our specified version; however the Ant plugin must not inherit that, so it was doing it's own transitive dependency search of that range.

So the solution was (a) make sure that the code built with Ant wasn't importing code that relied on Cats or (b) add an "exclusion" tag to the dependency that we pass to the Ant plugin.

So yeah... pretty obscure...

Upvotes: 1

Related Questions