maven命令

1.生命周期(lifecycle)和阶段(phase)

https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

maven定义了三个内置的(built-in)的生命周期(三个过程):

1.default:负责部署你的project(编译部署程序的一个过程)

2. clean:负责clean你的项目 (清理项目的一个过程)

3. site:负责创建你的项目的site documentation

 

每个lifecycle由若干个阶段(phase)构成,比如default生命周期由以下阶段构成:

validate: validate the project is correct and necessary information is available

compile:  compile the source code of the project

test:  test the compiled source code using a suitable unit testing framework. Theses tests should not require the code be packaged or deployed.

package: take the compiled code and package it in its distributable format, such as a  JAR.

verify:  run any checks on results of integration tests to ensure quality criteria are met.

install: install the package into the local repository, for use as a dependency in other projects locally.

deploy: done in the build environment, copies the final package to the remote repository for sharing with other develops and projects.

各个阶段phase是有先后顺序的

 

每一个phase阶段是由plugin goals构成的

一个plugin可以有多个goal,然后   插件的goal  和  phase绑定。

 

以下组件的 Enum LifecyclePhase定义了所有的phase:

 

<dependency>
    <groupId>org.apache.maven.plugin-tools</groupId>
    <artifactId>maven-plugin-annotations</artifactId>
    <version>3.3</version>
</dependency>

 

 

 

2.maven命令的格式:   

mvn  生命周期阶段   

或者   mvn groupId:artifactId:version:goal(这个是执行插件的命令格式)


1. mvn help:describe         查看插件  目标
2. mvn archetype:generate    创建新的maven项目
3. mvn dependency:sources    下载你项目依赖的资源的源代码
4. mvn compile                执行  default生命周期的编译阶段

5. mvn install                   执行default生命周期的install阶段:将jar部署到本地仓库

6. mvn deploy                 执行default生命周期的deploy阶段: 将jar部署到远程仓库

7.

mvn archetype:generate -DgroupId=com.xx.yyy -DartifactId=zzz -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

 

mvn  help:system 自动在本用户下创建   ~/.m2/repository

 

mvn clean  清理  执行 clean生命周期

 

mvn -U -Pauto clean  install -Dmaven.test.skip=true  安装到本地仓库

其中-U 强制更新snapshot类型的插件或者依赖库

-Pxxx  引用profile xxx

 

mvn clean -U package -pl  xxxModule  -am -P xxxprofileId  -Dmaven.test.skip=true

-pl  (等同于“--projects”)  build specified reactor projects instead of all projects.

选项后面跟groupid:artifactid  或者 所选模块的相对路径 (多个模块用逗号分隔)

-am(等同于“--also-make”)  If project list is specified, also build projects required by the list 表示同时处理选定模块(即-pl指定的模块)所依赖的模块

-amd 同 -am

 

mvn clean compile     清理编译
mvn clean test  清理测试
mvn clean package 清理打包
mvn clean install  -Pdev  清理将打包好的jar存入 本地仓库  注意是本地仓库   -P参数指定使用哪个profile,即“-Pproduct”就是选择product profile
mvn clean install -Dmaven.test.skip=true
mvn clean install -DskipTests
mvn archetype:generate 使用Archetype生成项目骨架
mvn clean deploy  根据pom中的配置信息将项目发布到远程仓库中

  mvn dependency:list   显示所有已经解析的依赖
  mvn dependency:tree   以目录树的形式展现依赖,最高层为第一层依赖,其次二层, 三层......
  mvn dependency:analyze 第一部分显示 已经使用但是未显示依赖的的  第二部分显示项目未使用的但是依赖的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值