I have a Java Maven project with several modules. When referencing to the parent module from the individual modules, the following information is added to project A\module-sample-app\pom.xml
:
<groupId>org.apache.maven</groupId>
<artifactId>module-sample-app</artifactId>
<packaging>jar</packaging>
<name>module-sample-app</name>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>sample-app-parent</artifactId>
<version>1.0-${buildLifeId}</version>
</parent>
The parent application A
has the following entry in A\pom.xml
:
<artifactId>A</artifactId>
<packaging>jar</packaging>
<name>A</name>
<version>1.0-${buildLifeId}</version>
To run the build, the following is executed on the parent directory of project A
:
Example: mvn clean install -DbuildLifeId=1001
The JAR file generated has an embedded pom.xml
with string ${buildLifeId}
and not the value 1001
.
When trying to use on the module sample-app
in another application, B
, as the runtime variable was not replaced with the actual value, it is failing to fetch the dependency. Just to highlight, B
is not a module of A
.
In B\pom.xml
:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>module-sample-app</artifactId>
<version>1.0-1001</version>
</dependency>
With this dependency, as the pom.xml
embedded within the module-sample-app-1.0-1001.jar
would have the parent version defined as <version>1.0-${buildLifeId}</version>
, the dependency fails to load.
So my questions is - does Maven support a plugin that can replace the run time variables before packaging the pom.xml
into the JAR? Or is there a workaround. Can I use Ant plugins to replace the buildLiefeId
variable in the version node to actual value when JAR is built?