war to ear

Assume you have already package, and install your war file to your local maven repo:

  1. Create a Maven project.
  2. In pom.xml do:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>YOUR-PROJECT-GROUPD-ID</groupId>
    <artifactId>YOUR-ARTIFACTID-EAR</artifactId>
    <version>1.0.0</version>
    <name>NAME-OF-YOUR-PROJECT</name>
    <description>DESCRIPTION-Of-YOUR-PROJECT</description>
    <packaging>ear</packaging>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>THE-GROUP-ID-OF-YOUR-WAR</groupId>
            <artifactId>ARTIFACTID-ID-OF-YOUR-WAR</artifactId>
            <version>1.0.0</version>
            <type>war</type>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <artifactId>maven-ear-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <finalName>FINAL-NAME-OF-YOUR-PROJECT</finalName>
                    <generatedDescriptorLocation>${basedir}/src/main/application/META-INF</generatedDescriptorLocation>
                    <modules>
                        <webModule>
                            <groupId>THE-GROUP-ID-OF-YOUR-WAR</groupId>
                            <artifactId>ARTIFACTID-ID-OF-YOUR-WAR</artifactId>
                            <uri>cmdctr-svc</uri>
                            <bundleFileName>FILE-NAME.ear</bundleFileName>
                            <contextRoot>/your_context_root</contextRoot>
                        </webModule>
                    </modules>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>