I'd create a new module that has .<packaging>ear</packaging>
In the dependencies for this ear module, include your module:war
<dependency>
<groupId>com.your.group.id</groupId>
<artifactId>your-war-artifact</artifactId>
<version>your-war-version</version>
<type>war</type>
</dependency>
Now in the build plugins for this ear module, include the maven-ear-plugin like, e.g.:
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>MyEarFile</finalName>
<version>5</version>
<generatedDescriptorLocation>${basedir}/src/main/application/META-INF</generatedDescriptorLocation>
<modules>
<webModule>
<groupId>com.your.group.id</groupId>
<artifactId>your-war-artifact</artifactId>
<uri>YouWarFile.war</uri>
<bundleFileName>YouWarFile.war</bundleFileName>
<contextRoot>/appname</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
You can change the specific configuration values for the as required.webModule
Now create a parent module (with ) and add the war module and the ear module to it. Make sure you set the of the war and ear modules corrently. <packaging>pom</packaging>
<parent>
When you run for this new parent, a war file will be built by the war module and an ear file (containing the war) will be built by the ear module.mvn package