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
${basedir
} represents the directory containing pom.xml${version
} equivalent to${project.version
} (deprecated:${pom.version
})
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.
outputD
irectory
}
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.
${my.filter.value
} will result inhello
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()
.
Franz Allan Valencia See
o project.distributionManagementArtifactRepository
o project.artifact
o project.parent
o project.file
o project.artifacts
o project.parentArtifact
o project.pluginArtifacts
o project.remoteArtifactRepositories
o project.pluginArtifactRepositories
o project.attachedArtifact
* settings (from [2])
o settings.offilne
o settings.interactive
* rootless (from [3])
o localRepository
o reactorProjects
* java properties (from [4])
o java.version
o java.vendor
o java.vendor.url
o java.home
o java.vm.specification.version
o java.vm.specification.vendor
o java.vm.specification.name
o java.vm.version
o java.vm.vendor
o java.vm.name
o java.specification.version
o java.specification.vendor
o java.specification.name
o java.class.version
o java.class.path
o java.library.path
o java.io.tmpdir
o java.compiler
o java.ext.dirs
o os.name
o os.arch
o os.version
o file.separator
o path.separator
o line.separator
o user.name
o user.home
o user.dir
Franz
[2] http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.xml
[3] http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml
[4] http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties
John Martin
Bjorn De Bakker
<version>$
Franz Allan Valencia See
Franz
Tjeerd Verhagen
See http://altuure.blogspot.com/2006/11/maven-profiles.html for an example.
Emmanuel Hugonnet
I would like to know this very much
Jamie Burrell
For example, given the following in the POM:
<
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
>
${project.developers.0.id
} in the POM would then return"myUserId"
./home/group/userid
).Nicolas Kyriazopoulos-Panagiotopoulos
<my.filter.value>
<items>
<item>hello</item>
<item>world</item>
</items>
</properties>Thaanks in advance!
Amit
QA_2
Thomas Franconville
Chris Laprun
${maven.repo.local
} doesn't seem to be working anymore...astroxl
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>mysql</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assemblies/descriptor.xml</descriptor>
</descriptors>
[...]
Nicolas Toublanc
maven.build.timestamp
Marco Soldati
Johann Renck
....
<
plugin
>
<
artifactId
>maven-antrun-plugin</
artifactId
>
<
version
>1.6</
version
>
<
executions
>
<
execution
>
<
phase
>install</
phase
>
<
configuration
>
<
tasks
>
<
echoproperties
/>
</
tasks
>
</
configuration
>
<
goals
>
<
goal
>run</
goal
>
</
goals
>
</
execution
>
</
executions
>
</
plugin
>
</
plugins
>
</
build
>
Pino Silvaggio
(home:bitstrings.org)