Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the announcement. Users are encouraged to migrate to the current version of Apache Maven.

ear settings

PropertyOptional?DescriptionDefault
maven.ear.final.name Yes Name of the generated EAR file. ${maven.final.name}.ear
maven.ear.manifest Yes Location of the manifest file to be used within the ear file. ${maven.ear.src}/META-INF/MANIFEST.MF
maven.ear.displayname Yes Display name of the application to be used when application.xml file is autogenerated ${pom.artifactId}
maven.ear.resources Yes Directory that resources are copied to during the build.NOTE: cannot have the same value of ${maven.ear.src}! ${maven.build.dir}/ear
maven.ear.src Yes Single directory for extra files to include in the EAR. NOTE: cannot have the same value of ${maven.ear.resources}! ${maven.src.dir}/application
maven.ear.descriptordir Yes Directory where the application.xml file will be auto-generated (only if maven.ear.appxml.generate is true). ${maven.build.dir}
maven.ear.appxml Yes Location of the application.xml file to be used within the ear file. ${maven.ear.src}/META-INF/application.xml
maven.ear.appxml.generate Yes Indicates if application.xml files should be autogenerated false
maven.ear.appxml.version Yes Inserts the doctype header depending on the specified version. 1.3
maven.ear.appxml.encoding Yes Character encoding for the auto-generated application.xml file. UTF-8
maven.ear.appxml.description Yes The description element inserted in the descriptor. ${pom.description}
maven.ear.appxml.securityRoles Yes A comma-separated list of role names. Will create xml element security-role with sub-element role-name. Empty

other settings

PropertyDescriptionSee
maven.build.dir where the component will be assembled maven.build.dir
maven.final.name The assembled component will be ${maven.build.dir}/${maven.final.name}.ear maven.final.name

Including artifacts in the ear file

You must tell Maven what artifact you want to include in the ear. This operation is type sensitive. Maven can bundle in ear artifacts of following types: jar, war, ejb, rar, sar. Artifacts of other types are ignored. This is achieved by specifying meta-information in the POM, using the following syntax:

    <dependency>
      <groupId>groupId</groupId>
      <artifactId>ejbArtifactId</artifactId>
      <version>aversion</version>
      <type>ejb</type>
      <properties>
        <ear.bundle>true</ear.bundle>
      </properties>
    </dependency>
  

Those artifacts will be also "visible" during generation of application.xml file. In case of war artifacts you can also specify context root which will be set in application.xml file:

    <dependency>
      <groupId>groupId</groupId>
      <artifactId>warArtifactId</artifactId>
      <version>aversion</version>
      <type>war</type>
      <properties>
        <ear.bundle>true</ear.bundle>
        <ear.appxml.war.context-root>webapp</ear.appxml.war.context-root>
      </properties>
    </dependency>
  

Note that by default the artifacts will be bundled in the EAR's root directory. To change the location where an artifact is bundled, please use the ear.bundle.dir property:

    <dependency>
      <groupId>groupId</groupId>
      <artifactId>jarArtifactId</artifactId>
      <version>aversion</version>
      <type>jar</type>
      <properties>
        <ear.bundle>true</ear.bundle>
        <ear.bundle.dir>APP-INF/lib</ear.bundle.dir>
      </properties>
    </dependency>
  

(it does not matter if the value of ear.bundle.dir starts with a slash (/) or not - it will always be relative to the root of the EAR)

It is also possible to change the name by which the dependency will be bundles using the ear.bundle.name property:

    <dependency>
      <groupId>groupId</groupId>
      <artifactId>jarArtifactId</artifactId>
      <version>aversion</version>
      <type>jar</type>
      <properties>
        <ear.bundle>true</ear.bundle>
        <ear.bundle.name>aJar</ear.bundle.name>
      </properties>
    </dependency>
  

In the example above, the dependency will be bundled simply as aJar and not jarArtifactId.aversion; note that ear.bundle.name and ear.bundle.dir can be used together:

    <dependency>
      <groupId>groupId</groupId>
      <artifactId>jarArtifactId</artifactId>
      <version>aversion</version>
      <type>jar</type>
      <properties>
        <ear.bundle>true</ear.bundle>
        <ear.bundle.name>aJar</ear.bundle.name>
        <ear.bundle.dir>/anotherDir</ear.bundle.dir>
      </properties>
    </dependency>
  

Finally, please note that if a jar is a java client module, you will need to declare it using the ear.module property, rather than ear.bundle:

    <dependency>
      <groupId>groupId</groupId>
      <artifactId>jarArtifactId</artifactId>
      <version>aversion</version>
      <type>jar</type>
      <properties>
        <ear.module>true</ear.module>
      </properties>
    </dependency>