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
.
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.
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.