Accessing BOM information from a Maven projet using that BOM

45 Views Asked by At

I have a BOM project which contains some information for some dependencies, with a pom.xml like this for example :

[...]

<dependencyManagement>
  <dependencies>
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.13.0</version>
    </dependency>
  </dependencies>
</dependencyManagement>

[...]

Naturally, I'm referencing that BOM in some Maven project that uses the same dependency but without the version, since it will be resolved from the BOM.

However, I would need to access and retrieve the version of the dependencies contained in the BOM from the Maven project (the one using the BOM). Let's say I need the version of commons-lang3 to be in the description of the pom.xml of my project, like :

<description>(insert here variable or something to retrieve the version from BOM)</description>

To achieve this, I could use a plugin in the BOM to write the contents of the pom.xml to a file like versions.properties and then read that file with the same plugin from the project. However, that kind of defeats the whole purpose of the BOM.

I checked the Maven Dependency Plugin and there might be something in it to help me, but I haven't had any luck finding anything yet.

0

There are 0 best solutions below