Maven内嵌变量收集,以及解释

There are some implicit properties available in any Maven project, these implicit properties are:
project.*
Maven Project Object Model (POM). 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 like PATH and M2_HOME can be referenced using the env.* prefix.
System Properties
Any property which can be retrieved from the System.getProperty() method can be referenced as
a Maven property.

The following list shows some common property references from the Maven project.

project.groupId and project.version
Projects in a large, multi-module build often share the same groupId and version identifiers. When
you are declaring interdependencies between two modules which share the same groupId and version,
it is a good idea to use a property reference for both:

<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>sibling-project</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

project.artifactId
A project’s artifactId is often used as the name of a deliverable. For example, in a project with WAR
packaging, you will want to generate a WAR file without the version identifiers. To do this, you would
reference the project.artifactId in your POM file like this:
<build>
    <finalName>${project.artifactId}</finalName>
</build>

project.name and project.description
The name and project description can often be useful properties to reference from documentation. Instead of
having to worry that all of your site documents maintain the same short descriptions, you can just reference
these properties.

project.build.*
If you are ever trying to reference output directories in Maven, you should never use a literal value like
target/classes. Instead you should use property references to refer to these directories.
    • project.build.sourceDirectory
    • project.build.scriptSourceDirectory
    • project.build.testSourceDirectory
    • project.build.outputDirectory
    • project.build.testOutputDirectory
    • project.build.directory

project.baseUri
If you need a valid URI for your project’s base directory, you can use the ${project.baseUri}
property. If your project is stored in the directory /tmp/simple, ${project.baseUri} will resolve
to file:/private/tmp/simple/.
Maven: The Complete Reference

Other Project Property references
There are hundreds of properties to reference in a POM. A complete reference for the POM structure is
available at http://maven.apache.org/ref/3.0.3/maven-model/maven.html

原文地址:https://www.cnblogs.com/zhangqingsh/p/2969116.html