'Maven BOM-of-BOM to capture submodules

I'm trying to make an internal-bom of related Maven projects, many of which have their own sub-modules. I don't want to reference every sub-module so am looking to produce a bom-of-bom using their reactor.

To the best of my knowledge, Maven's <scope>import</scope> inlines the <dependencyManagement> of a given artifact. I would like something similar that pulls in (only) the modules of a POM. It is not uncommon for a reactor to also be a parent which manages common external dependencies as well as inter-module references. internal-bom should not have any external references.


<!-- Couldn't Maven declare a new scope that inlines GAV references of these modules :( -->
<modules>
  <module>apple</module>
  <module>banana</module>
</modules>

<dependencyManagement>
  <dependencies>
    <!-- Here are the module dependencies we'd like -->
    <dependency><groupId>${project.groupId}</groupId><artifactId>apple</artifactId><version>${project.version}</version><dependency>
    <dependency><groupId>${project.groupId}</groupId><artifactId>banana</artifactId><version>${project.version}</version><dependency>

    <!-- Here are an arbitrary number of common externals -->
    <dependency><groupId>org.junit</groupId><artifactId>junit</artifactId><version>4.11</version><dependency>
  </dependencies>
</dependencyManagement>

Is there any way to achieve this? I'm aware I could update every project to also include a project-bom module that only has those module references. It's a lot of busy-work for little gain.

The question is probably coming from the same thought as Maven BOM: Super BOM which gathers all BOMs? and Publish a bom from a multi-module-project



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source