Maven使用介绍(三)
来源:互联网 发布:剑灵卡刀软件2017 编辑:程序博客网 时间:2024/06/05 00:35
再介绍几个其它命令:
- mvnsite : 为你的project创建一个站点
- mvnclean: 清除target目录下的所有文件
- mvneclipse:eclipse :为project生成eclipse的工程文件和classpath文件
build lifecycle &build phase & goal
maven有一套build的生命周期,是按照一套顺序走下来的,这一套顺序就叫一个生命周期(lifecycle)。maven内置三种生命周期:default,clean 和 site。一个生命周期分为多个build phase,下面是default生命周期全部的buildphase:
- validate:validate the projectis correct and all necessary information is available.
- initialize:initialize buildstate, e.g. set properties or create directories.
- generate-sources:generate anysource code for inclusion in compilation.
- process-sources:process thesource code, for example to filter any values.
- generate-resources:generateresources for inclusion in the package.
- process-resources:copy andprocess the resources into the destination directory, ready forpackaging.
- compile:compile the source codeof the project.
- process-classes:post-processthe generated files from compilation, for example to do bytecodeenhancement on Java classes.
- generate-test-sources:generateany test source code for inclusion in compilation.
- process-test-sources:processthe test source code, for example to filter any values.
- generate-test-resources:createresources for testing.
- process-test-resources:copy andprocess the resources into the test destinationdirectory.
- test-compile:compile the testsource code into the test destination directory
- process-test-classes:post-processthe generated files from test compilation, for example to dobytecode enhancement on Java classes. For Maven 2.0.5 andabove.
- test:run tests using a suitableunit testing framework. These tests should not require the code bepackaged or deployed.
- prepare-package:perform anyoperations necessary to prepare a package before the actualpackaging. This often results in an unpacked, processed version ofthe package. (Maven 2.1 and above)
- package:take the compiled codeand package it in its distributable format, such as aJAR.
- pre-integration-test:performactions required before integration tests are executed. This mayinvolve things such as setting up the requiredenvironment.
- integration-test:process anddeploy the package if necessary into an environment whereintegration tests can be run.
- post-integration-test:performactions required after integration tests have been executed. Thismay including cleaning up the environment.
- verify:run any checks to verifythe package is valid and meets quality criteria.
- install:install the packageinto the local repository, for use as a dependency in otherprojects locally.
- deploy:done in an integrationor release environment, copies the final package to the remoterepository for sharing with other developers andprojects.
这些build phase是按照顺序执行的,如果执行后面的buildphase,前面的build phase 也会被执行。例如如果执行:
mvn deploy
前面的install、verify一直到validate这些buildphase都会执行。
每一个buildphase是由goal组成的,一个goal其实就是一个任务,一个goal可以关联到一个buildphase也可以不关联到任何build phase 。 不关联到任何phase的goal是可以独立执行的,例如:
mvn clean dependency:copy-dependencies package
上面的命令会导致先执行clean这个phase,然后拷贝依赖项,最后打包。注意,这里clean这个goal是clean这个lifecycle里面的一个goal,所以可以看到不同lifecycle的buildphase和goal是可以混合在一起执行的。如果一个goal被绑定到多个phase上,那么goal就会被执行多次。
phase的顺序是已经固定的,如果一个phase没有绑定到任何goal,那么phase就不会被执行。一个goal可以通过两种方式绑定到一个phase,一个是指定packaging,另一个就是plugin。
- Maven使用介绍(三)
- Maven(三)——profile介绍
- Maven使用介绍(一)
- Maven使用介绍(二)
- Maven使用介绍(四)
- maven使用总结(三)
- Maven详解(三)------ Maven工程目录介绍
- MPC使用介绍(三)
- maven使用入门介绍
- Maven 使用介绍
- Maven 介绍、安装使用
- maven使用入门介绍
- Maven 使用介绍
- Maven 使用介绍
- Maven介绍与使用
- Maven 使用介绍
- Maven 使用介绍
- Maven 使用介绍
- 《Friends》里经典100句!好…
- Android中关于SQLite的操作
- Eclipse下的java工程目录
- Maven使用介绍(一)
- Maven使用介绍(二)
- Maven使用介绍(三)
- Maven使用介绍(四)
- Jquery基础之DOM操作
- SSH
- Java注释规范
- Java反射机制
- Java反射机制例子(一)
- @RequestMapping 用法…
- PE文件