官網文檔
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html 靠譜
lifecycle
lifecycle 是maven最高流程的抽象概念,定義了project(軟件工程解決方案)的通用流程,每個lifecycle定義了一定順序的phase,每個phase用來執(zhí)行特定的構建步驟
三種內置的lifecycle
default
The default lifecycle handles your project deployment, include following phase:
- validate
- compile
- test
- package
- verify
- install
- deploy
clean
- pre-clean
- clean
- post-clean
site
- pre-site
- site
- post-site
- site-deploy
phase
每個pharse用來執(zhí)行特定的構建步驟, 一定順序的phase組成lifecycle
plugin goals & phase
- goals 用來執(zhí)行一定的功能,可以自定義實現,實現的功能比較廣。
- phase 由一些列的goals組成。
- 也可以將goal 綁定到聲明周期對應的phase
內建綁定
自定義綁定
創(chuàng)建項目的源碼jar:
- mvn source:jar-no-fork
- 自定義綁定phase
<build>
<plugins>
<!-- 自定義綁定,創(chuàng)建項目的源碼jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<!-- 配置一個執(zhí)行任務-->
<execution>
<id>attach-sources</id>
<!-- 通過phase綁定到verify的生命周期上 -->
<phase>verify</phase>
<goals>
<!-- 插件目標 -->
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>