在Maven的pom.xml文件中,Build相关配置包含两个部分,一个是<build>,另一个是<reporting>,这里我们只介绍<build>。
1. 在Maven的pom.xml文件中,存在如下两种<build>:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<!-- "Project Build" contains elements of the BaseBuild set and the Build set-->
<build>...</build>
<profiles>
<profile>
<!-- "Profile Build" contains elements of the BaseBuild set only -->
<build>...</build>
</profile>
</profiles>
</project>
说明:
一种<build>被称为Project Build,即是<project>的直接子元素。另一种<build>被称为Profile Build,即是<profile>的直接子元素。
Profile Build包含了基本的build元素,而Project Build还包含两个特殊的元素,即各种<...Directory>和<extensions>。
2. Profile Build和Project Build共用的基本build元素
1) 示例如下:
<build>
<defaultGoal>install</defaultGoal>
<directory>${basedir}/target</directory>
<finalName>${artifactId}-${version}</finalName>
...
</build>