Inherit dependency versions from a pom file

I have an existing pom.xml file which has dependencyManagement version. this file is deployed to a central repository (Nexus-like) used by multiple projects throughout the company.
multiple maven projects refer to that pom file as “parent”.
then they declare dependencies without specifying their versions because those come from the parent pom file.

now I want to create a Gradle project that could use that pom.xml file to inherit dependency versions as well. is that possible?
for now I can ignore build plugins or dependencies declared in that parent, I’m mostly interested in inheriting specific version numbers plus maybe properties coming from the parent pom.xml file.

e.g. if the parent pom.xml file says “when you use Apache libraryX, you should use version Y” and then I can declare in my build.gradle file:

  1. refer to this pom file in the central repository
  2. use Apache LibraryX without specifying version number - because that will come from the pom file

Hi Alex,

I think currently the option to directly do that is to use the plugin the Spring project created to enable the usage of Bill-of-Material (BOM) POM descriptors in a gradle build.

You might find some information in the inaugural blog post [1] and the Github project [2].


1 Like

Neflix has open sourced their plugin to do this as well.

thanks a lot! I used “io.spring.gradle” and it worked just fine!

Support for this is now natively available in Gradle 5, and is fully realized in Gradle 5.2.1.

See the java-platform plugin documentation for details.