<sourceDirectory>${basedir}/src</sourceDirectory>
<outputDirectory>${basedir}/WebRoot/WEB-INF/classes</outputDirectory>
Available Variables
Project Model Variables
Any field of the model that is a single value element can be referenced as a variable. For example, ${project.groupId}, ${project.version}, ${project.build.sourceDirectory} and so on. Refer to the POM reference to see a full list of properties.
These variables are all referenced by the prefix "project.". You may also see references with pom. as the prefix, or the prefix omitted entirely - these forms are now deprecated and should not be used.
Special Variables
| basedir | The directory that the current project resides in. |
| project.baseUri | The directory that the current project resides in, represented as an URI. Since Maven 2.1.0 |
| maven.build.timestamp | The timestamp that denotes the start of the build. Since Maven 2.1.0-M1 |
The format of the build timestamp can be customized by declaring the property maven.build.timestamp.format as shown in the example below:
<project>
...
<properties>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
</properties>
...
</project>
The format pattern has to comply with the rules given in the API documentation for SimpleDateFormat. If the property is not present, the format defaults to the value already given in the example.
Properties
You are also able to reference any properties defined in the project as a variable. Consider the following example:
<project>
...
<properties>
<mavenVersion>2.1</mavenVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>${mavenVersion}</version>
</dependency>
</dependencies>
...
</project>
本文介绍了Maven项目中可用的各种变量与属性,包括项目的模型变量、特殊变量及自定义属性。通过这些变量,可以方便地引用项目元数据,如项目组ID、版本号等,并能自定义构建时间戳格式。
1168

被折叠的 条评论
为什么被折叠?



