标签:
三条独立的生命周期、同一生命周期内的阶段存在依赖关系
Clean Lifecycle
pre-clean
clean
post-clean
Default Lifecycle
validate
initialize
generate-sources
process-sources
generate-resources
process-resources
compile - 编译项目的主代码
process-classes
generate-test-sources
process-test-sources
generate-test-resources
process-test-resources
test-compile
process-test-classes
test
prepare-package
package - 接受编译好的代码,打包成可发布的格式,如jar
pre-integration-test
integration-test
post-integration-test
verify
install 将包安装到Maven本地仓库
deploy 将最终的包复制到远程仓库
Site Lifecycle
pre-site
site
post-site
site-deploy - 将生产的项目站点发布到服务器上
插件绑定
生命周期各过程是通过绑定的插件实现的,默认的绑定参见:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
查看插件的默认绑定阶段
mvn help:describe -Dplugin = org.apache.maven.plugins:maven-source-plugin:2.1.1-Ddetail
自定义绑定
在pom.xml中
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.1.1</version> <executions> <execution> <id>attact-sources</id> <phase>verify</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
插件配置
命令行配置 如 mvn install -Dmaven.test.skip = true
pom中全局配置 如
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
标签:
原文地址:http://www.cnblogs.com/idel/p/4323084.html