Fork me on GitHub

Usage

Simply add the plugin to the build section of your top-level POM as following.

  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.7.2</version>
        <configuration>
        </configuration>
        <executions>
          <!-- enable flattening -->
          <execution>
            <id>flatten</id>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <!-- ensure proper cleanup -->
          <execution>
            <id>flatten.clean</id>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
      

NOTICE

The generated flattened POM will be set as POM file to the current project only for projects with packaging other than pom. You may want to also do this for pom packaging projects by setting the parameter updatePomFile to true.

If flattenMode is set to bom the generated flattened POM will be set as a project POM file also for pom packaging.

Setting generated flattened POM as a project POM file will allow to install/deploy the generated POM instead of actual project POM file.

Keep developer information

If you want to keep additional development information in your POM you can configure predefined modes via the flattenMode parameter. For typical open-source-projects you can choose "oss". To keep all additional POM elements and flatten only to a bare minimum use "resolveCiFriendliesOnly". Here is an example configuration:

        <configuration>
          <flattenMode>resolveCiFriendliesOnly</flattenMode>
        </configuration>