Maven - (Property|Filter)

Card Puncher Data Processing


A property is used to supplied value of resource files at build time. This process is called filtering.

A property can be:

  • one of the values defined in your pom.xml,
  • a value defined in the user's settings.xml,
  • an environment variable
  • a property defined in an external properties file,

How to

Enable filtering

Filtering is dsiable by default. To enable it, you must modify the filtering element of the Pom.xml.


Define a property



External properties file

In src/main/filters/



The external property file must be defined in the POM.xml


Configuration Property

To reference a property from the configuration files, the property name uses the following syntax:



Some elements have default values and then don't need to be explicitly defined.


  • refers to the name of the project,
  • pom.version refers to the version of the project,
  • refers to the final name of the file created when the built project is packaged,
  • settings.localRepository refers to the path of the user's local repository).
  • env.myEnvironmentVariableName refers the the environment variable myEnvironmentVariableName

System properties

Filtering resources can also get values from system properties built into Java like:

  • java.version
  • user.home

Command Line

Properties can also be defined on the command line using the standard Java -D parameter.

Example: To define the property command.line.prop with the value “hello again”

mvn process-resources "-Dcommand.line.prop=hello again"

Environment variable

Process / Thread - Environment Variable


Built-in properties

Use them

The property values will be supplied when the resource is filtered.

Example: in the src/main/resources directory


Start filtering

mvn process-resources

Documentation / Reference

Discover More
Card Puncher Data Processing
Maven - Home (m2_home|maven.home)

The Maven installation directory can be: configured with the environment variable M2_HOME used in the configuration files with the property
Card Puncher Data Processing
Maven - Resources

Maven supports two kinds of resources. application resources or resources that the application needs Default location: /src/main/resources Test resources used during the test phase and that...
Card Puncher Data Processing
Maven - Settings.xml - (User|Local) Configuration

Settings.xml is a configuration file that should not be bundled to any specific project pom.xml It contains: configuration information such as the local repository location authentication information...
Card Puncher Data Processing
Maven - Variable


Share this page:
Follow us:
Task Runner