How to use MVN CLEAN INSTALL In ECLIPSE
1, or in the Maven project pom.xml Right -> Run As -> "Maven Build ..." or Run Configuration -> "Maven Build"
2, in the input box "Goals": clean install -X
3, use can be selected in the Run As Maven build in
Several mvn command:
-
mvn -h, when not used, it can help.
-
mvn clean compile, will be compiled into .class .java class file;
-
mvn clean test, unit testing. In essence, or to perform a complete life cycle, clean: clean, resources: resources, compiler: compile, resources: testResources, compiler: testCompile
-
mvn clean package, packaged.
-
mvn clean install –Dmaven.test.skip
-
Clean the install mvn , the package is mounted to a jar maven local repository.
-
mvn archetype: generate, quickly build project skeleton enter some groupId / artifactId / version information, and generates the necessary project dependencies automatically by skeleton mvn plug.
==========================================================================================================================
Use on what continuous integration server command mvn integration projects, the answer to this question is clear at first glance, not that mvn clean install it? In fact better integrated command a bit more complicated, here are some conclusions:
-
Do not forget to clean: clean to ensure the last construction will not affect the output of this building.
-
Use deploy instead install: build SNAPSHOT output should be automatically deployed to the private Maven repository for use by others, which have been discussed in detail at the front.
-
Use -U parameter: This parameter can force the Maven SNAPSHOT check all depend updated to ensure integration based on the latest state, if no parameters, Maven default in days to check for updates, and continuous integration of frequency should be much higher than this.
-
Use the -e option: If you build unusual, this parameter allows Maven to print the complete stack trace, in order to facilitate the analysis of the error.
-
Use -Dmaven.repo.local parameters: continuous integration server if there are many tasks, each task will use local repository, download the dependencies to a local warehouse, in order to avoid such a conflict to use multiple threads may cause local repository, you can use -Dmaven each task assigned local repository .repo.local = / home / juven / ci / foo-repo / this parameter.
-
Use -B parameters: This parameter allows Maven to build the project using batch mode, to avoid some of the pending state requires human interaction and participation caused.
-
Use -X parameters: Turn DEBUG mode.
In summary, the integrated command on the continuous integration server should mvn clean deploy -B -e -U -Dmaven.repo.local = xxx. In addition, regular cleaning of local Maven repository continuous integration server is also a good practice to avoid wasting disk resources, almost all of the continuous integration server software supports local scripting tasks, you can write a single line of shell scripts or bat, then configured in days automatically clean warehouse. It should be noted, do so on the premise that you have a private Maven repository, or download from the Internet every time all the dependencies would be a nightmare.
mvn clean install
Lifecycle Phase Description
validate | Verify the project is correct and complete in order to build all the necessary information is available |
generate-sources | 生成所有需要包含在编译过程中的源代码 |
process-sources | 处理源代码,比如过滤一些值 |
generate-resources | 生成所有需要包含在打包过程中的资源文件 |
process-resources | 复制并处理资源文件至目标目录,准备打包 |
compile | 编译项目的源代码 |
process-classes | 后处理编译生成的文件,例如对Java类进行字节码增强(bytecode enhancement) |
generate-test-sources | 生成所有包含在测试编译过程中的测试源码 |
process-test-sources | 处理测试源码,比如过滤一些值 |
generate-test-resources | 生成测试需要的资源文件 |
process-test-resources | 复制并处理测试资源文件至测试目标目录 |
test-compile | 编译测试源码至测试目标目录 |
test | 使用合适的单元测试框架运行测试。这些测试应该不需要代码被打包或发布 |
prepare-package | 在真正的打包之前,执行一些准备打包必要的操作。这通常会产生一个包的展开的处理过的版本(将会在Maven 2.1+中实现) |
package | 将编译好的代码打包成可分发的格式,如JAR,WAR,或者EAR |
pre-integration-test | 执行一些在集成测试运行之前需要的动作。如建立集成测试需要的环境 |
integration-test | 如果有必要的话,处理包并发布至集成测试可以运行的环境 |
post-integration-test | 执行一些在集成测试运行之后需要的动作。如清理集成测试环境。 |
verify | 执行所有检查,验证包是有效的,符合质量规范 |
install | 安装包至本地仓库,以备本地的其它项目作为依赖使用 |
deploy | 复制最终的包至远程仓库,共享给其它开发人员和项目(通常和一次正式的发布相关) |
mvn jar:jar JAR打包默认的目标
process-resources | resources:resources |
compile | compiler:compile |
process-test-resources | resources:testResources |
test-compile | compiler:testCompile |
test | surefire:test |
package | jar:jar |
install | install:install |
deploy | deploy:deploy |
POM打包默认的目标
package | site:attach-descriptor |
install | install:install |
deploy | deploy:deploy |
EJB打包默认的目标
process-resources | resources:resources |
compile | compiler:compile |
process-test-resources | resources:testResources |
test-compile | compiler:testCompile |
test | surefire:test |
package | ejb:ejb |
install | install:install |
deploy | deploy:deploy |
Maven提供了对EJB 2和3的支持。必须配置EJB插件来为EJB3指定打包类型,否则该插件默认认为EJB为2.1,并寻找某些EJB配置文件是否存在。
WAR打包默认的目标
process-resources | resources:resources |
compile | compiler:compile |
process-test-resources | resources:testResources |
test-compile | compiler:testCompile |
test | surefire:test |
package | war:war |
install | install:install |
deploy | deploy:deploy |
注意war:war
插件需要一个web.xml
配置文件在项目的src/main/webapp/WEB-INF
目录中。
EAR打包默认的目标 生命周期阶段 目标
generate-resources | ear:generate-application-xml |
process-resources | resources:resources |
package | ear:ear |
install | install:install |
deploy | deploy:deploy |
1, or in the Maven project pom.xml Right -> Run As -> "Maven Build ..." or Run Configuration -> "Maven Build"
2, in the input box "Goals": clean install -X
3, use can be selected in the Run As Maven build in
Several mvn command:
-
mvn -h, when not used, it can help.
-
mvn clean compile, will be compiled into .class .java class file;
-
mvn clean test, unit testing. In essence, or to perform a complete life cycle, clean: clean, resources: resources, compiler: compile, resources: testResources, compiler: testCompile
-
mvn clean package, packaged.
-
mvn clean install –Dmaven.test.skip
-
Clean the install mvn , the package is mounted to a jar maven local repository.
-
mvn archetype: generate, quickly build project skeleton enter some groupId / artifactId / version information, and generates the necessary project dependencies automatically by skeleton mvn plug.