Fork me on GitHub

Using flatten-maven-plugin in a simple project

Actually flatten-maven-plugin is designed for (large) multi-module-projects it can also be used for simple projects.

Single POM

If you have just a single POM add flatten-maven-plugin in the build section:
<!-- Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt -->
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example.whizbang</groupId>
  <artifactId>whizbang</artifactId>
  <version>3.1.7-SP2</version>
  <packaging>jar</packaging>

  <properties>
    <spring.version>4.0.2.RELEASE<spring.version>
  </properties>

  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <!--<version>1.0.1</version>-->
        <configuration>
        </configuration>
        <executions>
          <execution>
            <id>flatten</id>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <developers>
    <developer>
      <id>hohwille</id>
      <name>J&#246;rg Hohwiller</name>
      <email>hohwille@users.sourceforge.net</email>
    </developer>
  </developers>
  <licenses>
    <license>
      <name>Apache Software Licenese</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <comments/>
    </license>
  </licenses>
</project>
        
If you install or deploy the project the flattened POM of whizbang that goes into the repository will look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt -->
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example.whizbang</groupId>
  <artifactId>whizbang</artifactId>
  <version>3.1.7-SP2</version>
  <packaging>jar</packaging>
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>4.0.2.RELEASE</version>
    </dependency>
  </dependencies>
  <licenses>
    <license>
      <name>Apache Software Licenese</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <comments/>
    </license>
  </licenses>
</project>