官网文档
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html 靠谱
lifecycle
lifecycle 是maven最高流程的抽象概念,定义了project(软件工程解决方案)的通用流程,每个lifecycle定义了一定顺序的phase,每个phase用来执行特定的构建步骤
三种内置的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用来执行特定的构建步骤, 一定顺序的phase组成lifecycle
plugin goals & phase
- goals 用来执行一定的功能,可以自定义实现,实现的功能比较广。
- phase 由一些列的goals组成。
- 也可以将goal 绑定到声明周期对应的phase
内建绑定
自定义绑定
创建项目的源码jar:
- mvn source:jar-no-fork
- 自定义绑定phase
<build>
<plugins>
<!-- 自定义绑定,创建项目的源码jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<!-- 配置一个执行任务-->
<execution>
<id>attach-sources</id>
<!-- 通过phase绑定到verify的生命周期上 -->
<phase>verify</phase>
<goals>
<!-- 插件目标 -->
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>