Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do JVM build tools resolve dependencies with no identified version in the POM?

My project has a transitive dependency on Google’s guice library.

Guice’s POM contains dependencies that have no version info. For example:

<dependency>
  <groupId>javax.inject</groupId>
  <artifactId>javax.inject</artifactId>
</dependency>

I note that there is only one version of that particular library: 1.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I also note that there is no <dependencyManagement> node in the POM. There is a <parent> node, but its version ( 4 ) does not match javax.inject‘s version.
https://repo1.maven.org/maven2/com/google/inject/guice/4.0/guice-4.0.pom

So my question is:

How do build tools like mvn, gradle, and sbt determine (programatically) which version to download? (eg, 1. Given the lack of info.)

If you know the answer, is it officially documented anywhere?

Thanks.

>Solution :

The version is defined in the dependencyManagement of the parent POM.

Here you find the parent POM:

https://repo1.maven.org/maven2/com/google/inject/guice-parent/4.0/guice-parent-4.0.pom

If the version is missing, it comes from a parent POM, an imported BOM or dependencyManagement. In some cases, it may be hard to figure out the exact place because there may be a hierarchy of parent POMs and/or BOMs.

Maven never "guesses" the version of a dependency. For plugins, this is different. A missing version will lead to Maven downloading the newest version of the plugin it finds in the defined repositories.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading