Customizing The File Name Mapping

It might happen that you need to change the naming of the artifacts within the EAR file. This can be achieved by using the outputFileNameMapping. The following shows how it could be configured in your pom file.

In this example the default value is given as a starting point.

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
           [...]
           <outputFileNameMapping>@{groupId}@-@{artifactId}@-@{version}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
        </configuration>
      </plugin>
    </plugins>
  </build>

Based on the given things you can influence the resulting naming based on your wishes. For example you want to have all artifacts within your ear file without a version you can change the configuration like the following:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
           [...]
           <outputFileNameMapping>@{groupId}@-@{artifactId}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
        </configuration>
      </plugin>
    </plugins>
  </build>
  • @{dashClassifier?}@ - expands to a classifier including the preceding dash which is needed to separate it from other parts of the artifact
  • @{version}@ - expands to artifact version, for SNAPSHOT artifacts can contain timestamp postfix instead of SNAPSHOT
  • @{baseVersion}@ - expands to base artifact version, for SNAPSHOT artifacts we will always have SNAPSHOT postfix