Intro

Because I couldn't find a clear overview of which properties are availabe in maven2 I started this page. It is a collection of things found in the offcial maven documentation and postings to the maven user mailing list.

Note: In Maven 3.0, all pom.* properties are deprecated. Use project.* instead!

Built-in properties

Pom/Project properties

All elements in the pom.xml, can be referenced with the project. prefix. This list is just an example of some commonly used elements. (deprecated: {pom.} prefix)

${project.build.directory} results in the path to your "target" directory, this is the same as ${pom.project.build.directory}

${project.build.outputDirectory} results in the path to your "target/classes" directory

${project.name}refers to the name of the project (deprecated: ${pom.name} ).

${project.version} refers to the version of the project (deprecated: or ${pom.version}).

${project.build.finalName} refers to the final name of the file created when the built project is packaged

Local user settings

Similarly, values in the user's settings.xml can be referenced using property names with settings. prefix.

${settings.localRepository} refers to the path of the user's local repository

Environment variables

Environment variables can be referenced using the env prefix

${env.M2_HOME} returns the Maven2 installation path.

${java.home} specifies the path to the current JRE_HOME environment use with relative paths to get for example:<jvm>${java.home}../bin/java.exe</jvm>

Java system properties

All Java System Properties defined by the JVM.

Custom properties in the POM

User defined properties in the pom.xml.

<project>

...

<properties>

<my.filter.value>hello</my.filter.value>

</properties>

...

</project>

${my.filter.value} will result in hello if you inserted the above XML fragment in your pom.xml

Parent Project variables

How can parent project variables be accessed?

You can use the prefix: ${project.parent}.

A good way to determine possible variables is to have a look directly at the API. I'm currently using Maven 2.2.1, and to access the Parent you can use ${project.parent}. This will return an org.apache.maven.project.MavenProject instance.

To access the parent version: ${parent.version}.

Reflection Properties

The pattern ${someX.someY.someZ} can simply sometimes mean getSomeX().getSomeY().getSomeZ(). Thus, properties such as ${project.build.directory} is translated to getProject().getBuild().getDirectory().

Is it possible to add a property to your pom.xml? I mean, doing something like this:<version>$

Unknown macro: {app.version}

</version>

When you want to compile, just provide the value for the app.version via the command line. The problem is that we have several builds for one application (local, server, ...) and for that we need multiple properties-files, to change settings according to the location we're deploying it to.

Not sure if anyone else finds it useful (I know I did), but I have submitted a patch to plexus-utils that allows selection of properties from lists within the POM: http://jira.codehaus.org/browse/PLXUTILS-37For example, given the following in the POM:

pom.xml

<project>

...

<developers>

<developer>

<id>myUserId</id>

<name>Jamie Burrell</name>

<email>jamie.burrell@nospam.com</email>

<roles>

<role>developer</role>

</roles>

<timezone>0</timezone>

</developer>

<developer>

<id>herUserId</id>

<name>Jane Doe</name>

<email>jane.doe@nospam.com</email>

<organization>Doe Solutions</organization>

<roles>

<role>developer</role>

</roles>

<timezone>0</timezone>

</developer>

</developers>

...

</project>

Referencing ${project.developers.0.id} in the POM would then return "myUserId".

Not useful to everyone, but also not harmful, and allows access to all the list props on the POM (such as developers, contributors, profiles etc). I've been using it to automate directory path filtering for each developer (on *nix, the path is /home/group/userid).

I created this new plugin where it sets a property pointing to the artifact file for each selected project dependency. Each property name will have a base name in form of groupId:artifactId:type:[classifier][.relative][.suffix]. This is similar to the dependency:properties goal but with additional features, like filtering and relative paths.