Search code examples
mavenpom.xmlmaven-ear-plugin

Prevent maven building EAR twice


When building our EAR with maven I can see that during the build process the final EAR file is created, deleted and created from scratch again. Since it is quite a huge EAR (with lots of files) I would like to prevent that because:

  • it speeds up building process
  • it will improve the life time of the SSD

So the question is whether the first EAR file creation (which is immedeatly deleted afterwards) can be prevented (and if so how)?

<groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
        <earSourceDirectory>${basedir}/src/main/application</earSourceDirectory>
        <defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>  
        <archive>
            <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
        </archive>  
        <modules>
            <!-- some modules -->
        </modules>
    </configuration>
    <executions>
        <execution>
            <id>build-ear</id>
            <phase>package</phase>
            <goals>
                <goal>ear</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Solution

  • The addDefaultImplementationEntries tag is just useful for getting more implementation details in the MANIFEST.MF, by default the MANIFEST will be auto-generated when you build your project. More info here : http://maven.apache.org/shared/maven-archiver/examples/manifest.html

    And your ear seems to build two times due to the phase you have specified. You don't need to override the executions bloc, just remove it and it will work as you want.