Fork me on GitHub

Usage

read-project-properties

The properties:read-project-properties goal reads property files or URLs and stores them as project properties.

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>etc/config/dev.properties</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

or alternatively

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <urls>
                <url>classpath:/config/dev.properties</url>
                <file>file:///${env.HOME}/mydev.properties</file>
              </urls>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

write-project-properties

The properties:write-project-properties goal writes all project properties to a given file.

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>write-project-properties</goal>
            </goals>
            <configuration>
              <outputFile>
                ${project.build.outputDirectory}/app.properties
              </outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

write-active-profile-properties

The properties:write-active-profile-properties goal writes properties of all active profiles to a given file.

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>write-active-profile-properties</goal>
            </goals>
            <configuration>
              <outputFile>
                ${project.build.outputDirectory}/app.properties
              </outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

set-system-properties

The properties:set-system-properties goal sets the specified system properties.

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <goals>
              <goal>set-system-properties</goal>
            </goals>
            <configuration>
              <properties>
                <property>
                  <name>my.property.name</name>
                  <value>my.property.value</value>
                </property>
              </properties>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>