Maven technology Jane recorded
stage |
deal with |
description |
Validate validate |
Verification Project |
Verify that the project is correct and all necessary information is available |
Compiler compile |
Compile |
Source code is compiled at this stage |
Test Test |
test |
Using a suitable unit testing framework (e.g. the JUnit) running the test. |
Packing package |
Bale |
Create a package JAR / WAR package as defined in pom.xml mentioned |
Check verify |
an examination |
The results of integration testing checks to ensure that quality standards |
Install install |
installation |
Installing a packaged item to a local warehouse to use for other projects |
Deploy deploy |
deploy |
A copy of the final package to the remote repository project in order to share it with other developers and projects |
To complete the default life cycle, these phases (including other lifecycle stage is not listed above) to be executed sequentially.
Maven has a life cycle of the following three criteria:
Clean : clean up the processing project
default ( or Build) : project deployment process
site processing documents created project site:
clean and pakage is the construction phase, dependency: copy-dependencies goal is
mvn clean dependency:copy-dependencies package
Execute mvn post-clean command, Maven calls the clean life cycle, which includes the following phases:
clean-pre : the need to perform some clean done before work
Clean : Remove all previous build file generated
clean-POST : perform some necessary clean done immediately after work
Execute mvn clean will run the following two stages of the life cycle: pre-Clean, Clean
Run mvn POST-Clean , run the following three life cycle phases: pre-Clean, Clean, Clean-POST
Default (Build) life cycle
Life cycle stages |
description |
validate (check) |
Check items are correct and that all the necessary information to complete the process of building the project. |
initialize (initialization) |
Construction of the state initialization, such as setting the value of the attribute. |
generate-sources (generation sources) |
Any source code contains compiler generating stage. |
process-sources (the source code) |
Source code, for example, filtration arbitrary value. |
generate-resources (generation resource files) |
Generate resource files will be included in the project package. |
process-resources (process resources) |
Copy and processing resources to the destination directory for the packing stage the best preparation. |
compile (compiler) |
Compile the project source code. |
process-classes (class files processed) |
Compiled document processing, such as bytecode to do to improve the optimization of Java class files. |
generate-test-sources (generating test source code) |
Generate any test source code contained in the compilation stage. |
process-test-sources (treated test source code) |
Processing test source code, for example, filtration arbitrary value. |
generate-test-resources (generation of test resource file) |
Create a resource file for the test. |
process-test-resources (processing test resource file) |
Copy testing and treatment resources to the target directory. |
test-compile (compile test source code) |
Compile the test source code to the test destination directory. |
process-test-classes (class file processing test) |
Processing test file source compiler generates. |
test (test) |
Using a suitable run the test unit testing framework (JUnit is one). |
prepare-package (ready packed) |
Before the actual packaging, perform any necessary operations to prepare for the package. |
package (package) |
The compiled code can be packaged into distribution format files, such as JAR, WAR or EAR file. |
pre-integration-test (before integration testing) |
Make the necessary action before performing integration testing. For example, set up environmental needs. |
integration-test (integration test) |
Process and deploy the project to run an integrated test environment. |
post-integration-test (after integration testing) |
Make the necessary action after performing integration testing is complete. For example, clean up the integrated test environment. |
verify (verification) |
Run any checks to verify the project package is valid and meet quality standards. |
install (installation) |
Installation package to the local repository program, so that items can be used independent of other local packet items. |
deploy (deployment) |
Copy the final project package to the remote repository shared with other developers and projects. |
Command line call :
mvn install building, installation to a local warehouse
mvn clean deploy to build and deploy the project to a shared repository
Site Lifecycle
Maven Site plugin is generally used to create a new report documents, such as the deployment site.
Site-pre : perform some need to complete paperwork before generating station
Site : Build the project site documentation
post-site: 执行一些需要在生成站点文档之后完成的工作,并且为部署做准备
site-deploy:将生成的站点文档部署到特定的服务器上
Maven 插件通常被用来:
创建 jar 文件
创建 war 文件
编译代码文件
代码单元测试
创建工程文档
创建工程报告
插件 |
描述 |
clean |
构建之后清理目标文件。删除目标目录。 |
compiler |
编译 Java 源文件。 |
surefile |
运行 JUnit 单元测试。创建测试报告。 |
jar |
从当前工程中构建 JAR 文件。 |
war |
从当前工程中构建 WAR 文件。 |
javadoc |
为工程生成 Javadoc。 |
antrun |
从构建过程的任意一个阶段中运行一个 ant 任务的集合。 |
archetype 也就是原型,是一个 Maven 插件,准确说是一个项目模板,它的任务是根据模板创建一个项目结构。
mvn clean package -U maven 命令中使用 -U 参数强制 maven 现在最新的快照构建。
元素节点 |
描述 |
SCM |
配置 SVN 的路径,Maven 将从该路径下将代码取下来。 |
repository |
构建的 WAR 或 EAR 或JAR 文件的位置,或者其他源码构建成功后生成的构件的存储位置。 |
Plugin |
配置 maven-release-plugin 插件来实现自动部署过程。 |
mvn release:clean 清理工作空间,保证最新的发布进程成功进行。
mvn release:rollback 在上次发布过程不成功的情况下,回滚修改的工作空间代码和配置保证发布过程成功进行。
mvn release:prepare 执行多种操作:1.检查本地是否存在还未提交的修改 2.确保没有快照的依赖 3.改变应用程序的版本信息用以发布 4.更新POM文件到SVN 5.运行测试用例
6. 提交修改后的 POM 文件 7.为代码在 SVN 上做标记 8.增加版本号和附加快照以备将来发布 9.提交修改后POM文件到SVN
mvn release:perform 将代码切换到之前做标记的地方,运行 Maven 部署目标来部署 WAR 文件或者构建相应的结构到仓库里。