Maven笔记 - 3. Maven生命周期

2018-12-11  本文已影响0人  donglq

概念

Maven有3个内置生命周期

备注

生命周期的重要阶段

clean生命周期
site生命周期
default生命周期

关于阶段、插件和目标的表格

阶段 插件 目标
clean Maven Clean plugin clean
site Maven Site plugin site
process-resources Maven Resources plugin resource
compile Maven Compiler plugin compile
test Maven Surefire plugin test
package Varies based on the packaging; for instance, the Maven JAR plugin jar(in the case of a Maven JAR plugin)
install Maven install plugin install
deploy Maven deploy plugin deploy

配置文件

Maven提供了三种类型的配置文件

配置文件属性
pom.xml中
<profile>
    <id>test</id>
    <activation>...</activation>
    <build>...</build>
    <modules>...</modules>
    <repositories>...</repositories>
    <pluginRepositories>...</pluginRepositories>
    <dependencies>...</dependencies>
    <reporting>...</reporting>
    <dependencyManagement>...</dependencyManagement>
    <distributionManagement>...</distributionManagement>
</profile>
settings.xml中
<profile>
    <id>test</id>
    <activation>...</activation>
    <repositories>...</repositories>
    <pluginRepositories>...</pluginRepositories>
    <properties>…</properties>
</profile>
Profiles激活方式
mvn -P dev package
<activeProfiles>
    <activeProfile>dev</activeProfile>
</activeProfiles>
<profile>
    <activation>
        <property>
            <name>debug</name>
        </property>
    </activation>
    ...
</profile>

如果系统属性debug被定义并且有值,这个 profile会被激活。

<profile>
    <activation>
        <os>
            <family>Windows</family>
        </os>
    </activation>
    ...
</profile>

此配置在Windows系统中会被激活。

<profile>
    <activation>
        <file>
            <missing>target/site</missing>
        </file>
    </activation>
</profile>

如果target/site文件缺失,此配置将会激活。

属性

属性类型
上一篇 下一篇

猜你喜欢

热点阅读