Maven-publish plugin + multi-module + parent pom

I have a multi-project build that uses the maven-publish plugin [1] to generate Maven pom files.

Is it possible for this plugin to generate a parent pom and have the the module poms reference it?

For example, all of the dependencies shared by the modules and all of the Maven metadata would be in the parent pom and not repeated in each module pom.



Hi @bombinating-dev,

No it is not possible to generate parent poms with Gradle’s maven-publish. But I think there is no difference for the resolution result in having things repeated in each module compared to having common things in a parent POM. Why do you want to publish a parent pom?

You can define and publish a platform (BOM) by adding a java-platform project.

If you use Gradle Module Metadata, dependencies on the platform will be published and it will have a similar effect as a parent POM.

In Maven, the BOM would have to be imported explicitly in each build.

The reason I want to publish a parent POM is that I’m trying to port an existing Maven build to Gradle and the Maven build produces a parent POM (as most multi-module Maven builds do).

I was hoping to be able to generate from Gradle the same artifacts as generated by Maven to be able to verify that the two builds are equivalent but the parent POM makes the comparison more complicated.

But there’s good reason to want to set a parent to a generated BOM. For instance, if i want to generate a BOM that has spring-boot-dependencies as a parent.

Maven behaves differently if a BOM is a parent vs. an import - in that you can override dependency versions by overriding property versions if it’s a parent, but not so if it’s an import.

In my case I want to create a BOM that inherits from spring, that can then be inherited by other projects - allowing them to override based on properties.