Class GenerateBomMojo
- All Implemented Interfaces:
org.apache.maven.api.plugin.Mojo
Why this goal exists
Maven 4's consumer POM resolves property references in
<dependencies> but not in <dependencyManagement>.
When an external project imports a BOM via <scope>import</scope>,
it receives the consumer POM — so any ${…} expressions in managed
dependency versions arrive unresolved and the build fails.
flatten-maven-plugin, the Maven 3 solution for this class of
problem, has not been updated for the Maven 4 model changes.
This goal works around the limitation by reading the
<dependencyManagement> entries from a source module (default:
ike-parent) in the reactor, resolving every property reference to
a literal value, and writing a standalone BOM POM. The generated POM
replaces the stub POM for install/deploy, so external consumers get a
fully populated BOM without any manual maintenance. The generated POM
uses the 4.0.0 model version for maximum consumer
compatibility.
Usage
Bind this goal to a POM-packaged stub module in the reactor, ordered after the source module and the plugin module:
<plugin>
<groupId>network.ike</groupId>
<artifactId>ike-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-bom</id>
<goals><goal>generate-bom</goal></goals>
</execution>
</executions>
</plugin>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildBomXml(String groupId, String artifactId, String version, String name, String description, String url, List<BomEntry> entries) Build a complete BOM POM XML string from the given project coordinates and dependency entries.static StringEscape XML special characters in text content.voidexecute()protected org.apache.maven.api.plugin.LoggetLog()Access the Maven logger.
-
Constructor Details
-
GenerateBomMojo
public GenerateBomMojo()Creates this goal instance.
-
-
Method Details
-
getLog
protected org.apache.maven.api.plugin.Log getLog()Access the Maven logger.- Returns:
- the logger
-
execute
public void execute() throws org.apache.maven.api.plugin.MojoException- Specified by:
executein interfaceorg.apache.maven.api.plugin.Mojo- Throws:
org.apache.maven.api.plugin.MojoException
-
buildBomXml
public static String buildBomXml(String groupId, String artifactId, String version, String name, String description, String url, List<BomEntry> entries) Build a complete BOM POM XML string from the given project coordinates and dependency entries.This is a pure function with no Maven or I/O dependencies, suitable for direct unit testing.
- Parameters:
groupId- project group IDartifactId- project artifact IDversion- project versionname- project display name (XML-escaped internally)description- project description (may be null)url- project URL (may be null)entries- managed dependency entries- Returns:
- well-formed POM XML
-
escapeXml
-