I'm building a helper library for an external dependency. How can I make the version of my build take from the version of the external dependency?
<groupId>com.foo</groupId>
<artifactId>bar</artifactId>
<version>???</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.external.dependency</groupId>
<artifactId>bar</artifactId>
<version>3.0.42</version>
</dependency>
</dependencies>
</dependencyManagement>
I want my library to build as 3.0.42 as well to reflect that it's a helper for that version (and possibly some older versions) of that external dependency.
You can either follow @Thorbjørn's suggestion to use ${project.version}
in the dependency tag.
Alternatively, you can define a property <revision>
in the properties section of your POM (note that the name is important, don't try another property name) and define both the <version>
in the project and the library as ${revision}
.
The second approach requires a reasonably new Maven version (like 3.5.x or 3.6.x).