I have the following java/maven module structure:
myapp
|-application <- this is an ear assembler module
|-commons
|-restapi
I want to assemble an ear which contains renamed artifacts with correct version number of the boundled artifacts.
myapp-1.0.ear
|-myapp-commons-1.1.jar
|-myapp-restapi-1.2.war
I know that the name of the artifacts is similar with the name of the java module's name. Because I do not want to use 'myapp' prefixes before the module names therefore I need to rename the final name of the artifacts like this: myapp-[modulename]-[modulversion].jar|war.
My problem is if i use 'bundleFileName' configuration then I am not able to add version number info manually.
master pom:
<groupId>a.b.myapp</groupId>
<artifactId>myapp</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>application</module>
<module>commons</module>
<module>restapi</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>a.b.myapp</groupId>
<artifactId>restapi</artifactId>
<version>1.2</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
application.pom (ear module):
<parent>
<artifactId>myapp</artifactId>
<groupId>a.b.myapp</groupId>
<version>1.0</version>
</parent>
<artifactId>application</artifactId>
<version>1.0</version>
<packaging>ear</packaging>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>a.b.myapp</groupId>
<artifactId>restapi</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<finalName>${parent.artifactId}-${artifactId}-${version}</finalName> <-- MY-APPLICATION-1.0.EAR
<modules>
<webModule>
<groupId>com.remal.gombi</groupId>
<artifactId>restapi</artifactId>
<bundleFileName>${parent.groupId}-${artifactId}-${????}.war</bundleFileName> <- MYAPP-RESTAPI-???.WAR
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
restapi.pom
<parent>
<artifactId>myapp</artifactId>
<groupId>a.b.myapp</groupId>
<version>1.0</version>
</parent>
<artifactId>restapi</artifactId>
<version>1.2</version>
<packaging>war</packaging>
<modelVersion>4.0.0</modelVersion>
I am not able to get the version info of the 'restapi' module between the bundleFileName tags. If the bundleFileName property is not used then the name of the war file inside the ear will be restapi-1.2.war instead of myapp-restapi-1.2.war.
Could you please help me?
Possible solution:
Define a myapp.version property in the main pom file and use this variable everywhere when you need this info. For example you can use it between the <version>
tags and between <build>
<finalName>
tag as well.