What is the way to create a bom (java-platform) so...
# community-support
v
What is the way to create a bom (java-platform) so it does not require duplicating the list of “published” projects? Imagine I have projects
:core
and
:lib
, and
:test-fixtures
. Imagine I want publishing a platform that would align the versions of
:core
and
:lib
. I do not publish
:test-fixtures
and I use it for testing only, so I do not want including it to the bom. Of course, I can list
:bom
dependencies manually, however, it would be prone to errors as I might forget adding a module to the bom when adding a new module. I use convention plugins to configure the publication for
:core
and
:lib
modules, so I would like to configure
:bom
automatically for all the published projects. Can I somehow do that? I see JUnit uses
rootProject.extra
for storing the list of projects in a bom, however, it looks like it duplicates the configuration: • firstly, it list the projects in root project extra • secondly, the relevant subprojects have their publication configurations The configurations could deviate. For example, a new module could be added without updating root project extra. Is
rootProject.extra
the best we can have for now? Is it safe for configuration-cache/isolated-projects?
v
ext
/
extra
properties are usually always a work-around for not doing something properly. I learned from Gradle folks that you should feel dirty everytime you use them. I guess what you could do is to have a list of projects in the settings script, then iterate this list and call
include
for it and also set the list to a shared build service. Then in the platform project you can iterate the list in the build service to build up the dependencies.
v
include does not ensure the project will have id("maven-publish.convention") plugin
v
Then ensure it? For example have a convention plugin that you apply to all projects that apply that plugin to all projects on that list. It have some check that verifies that it is done consistently.
Or simply add a check to that publish convention plugin that ensures the current project is in that list in the service
As you need the information to build the platform at configuration time, there is not really a clean way I'm aware right now to get that information, except from the settings script or earlier.