Skip to content
Advertisement

How to pbulish a BOM out of gradle subprojects?

I have a multi module gradle build which a collection of reusable component projects and a collection of apps that use the common components.

JavaScript

In the example tree structure above the app:api project can use the components:clock project. I want to publish a Bill of Material (BOM) from all the component projects so that I can move components into it’s own repo.

How can I configure gradle to publish a BOM out of a collection of sub projects?

Advertisement

Answer

Gradle provides a special plugin to generate BOM artifacts (called Platforms in the Gradle world)

You can declare them using the java-platform plugin.

https://docs.gradle.org/current/userguide/java_platform_plugin.html

You can create an additional subproject that references all of your components projects. The maven-publish plugin works out of the box pretty much the same as with regular java projects and will publish a BOM POM.

I don’t have any samples in Kotlin syntax at hand, but basically the declaration looks pretty much the same as with regular dependencies but with an additional constraints block:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement