Fork me on GitHub

Plugin Documentation

Goals available for this plugin:

Goal Description
flatten:clean This MOJO realizes the goal flatten:clean that deletes any files created by flatten:flatten (more specific the flattened POM file which is by default .flattened-pom.xml). See also MOJO-2030 for further details.
flatten:flatten This MOJO realizes the goal flatten that generates the flattened POM and #isUpdatePomFile() potentially updates the POM file so that the current org.apache.maven.project.MavenProject's file points to the flattened POM instead of the original pom.xml file. The flattened POM is a reduced version of the original POM with the focus to contain only the important information for consuming it. Therefore information that is only required for maintenance by developers and to build the project artifact(s) are stripped. Starting from here we specify how the flattened POM is created from the original POM and its project:
Element Transformation Note
modelVersion Fixed to "4.0.0" New maven versions will once be able to evolve the model version without incompatibility to older versions if flattened POMs get deployed.
groupId
artifactId
version
packaging
resolved copied to the flattened POM but with inheritance from parent as well as with all variables and defaults resolved. These elements are technically required for consumption.
licenses resolved copied to the flattened POM but with inheritance from parent as well as with all variables and defaults resolved. The licenses would not be required in flattened POM. However, they make sense for publication and deployment and are important for consumers of your artifact.
Model#getDependencies() dependencies resolved specially flattened POM contains the actual dependencies of the project. Test dependencies are removed. Variables and Model#getDependencyManagement() dependencyManagement is resolved to get fixed dependency attributes (especially version). If #isEmbedBuildProfileDependencies() embedBuildProfileDependencies is set to true, then also build-time driven org.apache.maven.model.Profiles will be evaluated and may add dependencies. For further details see org.apache.maven.model.Profiles below.
profiles resolved specially only the org.apache.maven.model.Activation and the dependencies of a org.apache.maven.model.Profile are copied to the flattened POM. If you set the parameter embedBuildProfileDependencies to true then only profiles activated by JDK or OS will be added to the flattened POM while the other profiles are triggered by the current build setup and if activated their impact on dependencies is embedded into the resulting flattened POM.
name
description
url
inceptionYear
organization
scm
developers
contributors
mailingLists
Model#getPluginRepositories() pluginRepositories
issueManagement
ciManagement
Model#getDistributionManagement() distributionManagement
configurable Will be stripped from the flattened POM by default. You can configure all of the listed elements inside pomElements that should be kept in the flattened POM (e.g. <pomElements><name/><description/><developers/><contributors/></pomElements>). For common use-cases there are predefined modes available via the parameter flattenMode that should be used in preference.
prerequisites configurable Like above but by default NOT removed if packaging is "maven-plugin".
Model#getRepositories() repositories configurable Like two above but by default NOT removed. If you want have it removed, you need to use the parameter pomElements and configure the child element repositories with value flatten.
parent
build
Model#getDependencyManagement() dependencyManagement
Model#getProperties() properties
Model#getModules() modules
Model#getReporting() reporting
configurable These elements should typically be completely stripped from the flattened POM. However for ultimate flexibility (e.g. if you only want to resolve variables in a POM with packaging pom) you can also configure to keep these elements. We strictly recommend to use this feature with extreme care and only if packaging is pom (for "Bill of Materials"). In the latter case you configure the parameter flattenMode to the value bom.
If the build element contains plugins in the build/plugins section which are configured to load extensions, a reduced build element containing these plugins will be kept in the flattened pom.
flatten:help Display help information on flatten-maven-plugin.
Call mvn flatten:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 3.6.3
JDK 1.8

System Requirements History

The following specifies the minimum requirements to run this Maven plugin for historical versions:

Plugin Version Maven JDK
1.5.0 3.5.4 1.8
1.4.0 3.2.5 1.8

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>flatten-maven-plugin</artifactId>
          <version>1.6.0</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"