Maven Properties
You can use Maven properties in a pom.xml file or in any resource that is
being processed by the Maven Resource pluginâs filtering
features. A property is always surrounded by ${
and
}
. For example, to reference the
project.version
property, one would write:
${project.version}
Some implicit properties are available in any Maven project, namely:
project.*
Maven Project Object Model. You can use the
project.*
prefix to reference values in a Maven POM.settings.*
Maven settings. You use the
settings.*
prefix to reference values from your Maven settings in ~/.m2/settings.xml.env.*
Environment variables such as
PATH
andM2_HOME
can be referenced using theenv.*
prefix.- System properties
Any property that can be retrieved from the
System.getProperty()
method can be referenced as a Maven property.
In addition to these implicit properties, a Maven POM, Maven settings, or a Maven profile can define a set of arbitrary, user-defined properties. The following sections provide more detail on the various properties available in a Maven project.
Maven Project Properties
When a Maven Project Property is referenced, the property name
is referencing a property of the Maven Project Object
Model. Specifically, you are referencing a property of the
org.apache.maven.model.Model
class that is
being exposed as the implicit variable project. When you reference a
property using this implicit variable, you are using simple dot
notation to reference a bean property of the
Model
object. For example, ...
Get Maven: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.