The Ear plugin allows to generate automatically the descriptor deployment, e.g. application.xml. This generation is already customized by basic configuration items, see TODO: ADD A LINK HERE.
Ear modules might be further customized as follows:
Also, a dependency might be excluded from the generated EAR file by specifying the excluded flag.
Please note that third party libraries are not included in the generated application.xml (only ejb-client should be included in a java entry). However, a jar dependency could be included in the generated application.xml by specifying the includeInApplicationXml flag.
The sample below shows how to customize the context root of an artifact to be placed in the EAR file:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> [...] <modules> <webModule> <groupId>artifactGroupId</groupId> <artifactId>artifactId</artifactId> <contextRoot>/custom-context-root</contextRoot> </webModule> </modules> </configuration> </plugin> </plugins> </build>
The sample below shows how to place a library in the APP-INF/lib directory of the EAR file:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> [...] <modules> <javaModule> <groupId>artifactGroupId</groupId> <artifactId>artifactId</artifactId> <bundleDir>APP-INF/lib</bundleDir> </javaModule> </modules> </configuration> </plugin> </plugins> </build>
The sample below shows how to rename a module being placed in the EAR file:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> [...] <modules> <javaModule> <groupId>artifactGroupId</groupId> <artifactId>artifactId</artifactId> <bundleFileName>anotherName-1.2.3.jar</bundleFileName> </javaModule> </modules> </configuration> </plugin> </plugins> </build>
This is actually a combination of customizing the module's location and file name. The sample below shows how to specify the URI of a module being placed in the EAR file:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> [...] <modules> <javaModule> <groupId>artifactGroupId</groupId> <artifactId>artifactId</artifactId> <uri>APP-INF/lib/anotherName-1.2.3.jar</uri> </javaModule> </modules> </configuration> </plugin> </plugins> </build>
If for some reason a dependency which is declared in the pom of the project needs to be excluded, the excluded flag could be used as follows:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> [...] <modules> <javaModule> <groupId>artifactGroupId</groupId> <artifactId>artifactId</artifactId> <excluded>true</excluded> </javaModule> </modules> </configuration> </plugin> </plugins> </build>
If third party libraries need to be included in the generated application.xml, the 'includeInApplicationXml' flag could be used. This flag works only for java modules.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> [...] <modules> <javaModule> <groupId>artifactGroupId</groupId> <artifactId>artifactId</artifactId> <includeInApplicationXml>true</includeInApplicationXml> </javaModule> </modules> </configuration> </plugin> </plugins> </build>