Question

I want to package two .war files into an .ear file using the Maven EAR plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.8</version>
    <executions>
        <execution>
            <id>package-mae</id>
            <phase>package</phase>
            <configuration>
                <version>6</version>
                <modules>
                    <webModule>
                        <groupId>de.ast</groupId>
                        <artifactId>mae-mobile</artifactId>
                        <contextRoot>/mobile</contextRoot>
                        <bundleFileName>/mae-mobile.war</bundleFileName>
                    </webModule>
                    <webModule>
                        <groupId>de.ast</groupId>
                        <artifactId>mae-rest</artifactId>
                        <contextRoot>/api</contextRoot>
                        <bundleFileName>/mae-rest.war</bundleFileName>
                    </webModule>
                </modules>
            </configuration>
            <goals>
                <goal>generate-application-xml</goal>
                <goal>ear</goal>
            </goals>
        </execution>
    </executions>
</plugin>

It works nicely apart from the fact that the war files are packages twice each, i.e. the ear file contains:

  • mae-rest.war
  • mae-rest-0.0.1-SNAPSHOT.war
  • mae-mobile.war
  • mae-mobile-0.0.1-SNAPSHOT.war

How can I avoid this duplication?

Thanks, Ronald

Was it helpful?

Solution

I would suggest to change the configuration which you have into the following:

<build>
   <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.8</version>
        <configuration>
            <version>6</version>
            <modules>
                <webModule>
                    <groupId>de.ast</groupId>
                    <artifactId>mae-mobile</artifactId>
                    <contextRoot>/mobile</contextRoot>
                    <bundleFileName>mae-mobile.war</bundleFileName>
                </webModule>
                <webModule>
                    <groupId>de.ast</groupId>
                    <artifactId>mae-rest</artifactId>
                    <contextRoot>/api</contextRoot>
                    <bundleFileName>mae-rest.war</bundleFileName>
                </webModule>
            </modules>
            <generateApplicationXml>true</generateApplicationXml>
        </configuration>
      </plugin>
      ...
   </plugins>
</build>

This should solve your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top