maven生命周期所有阶段

什么是Maven构建生命周期? (What is Maven Build Lifecycle?)

When we build a Maven project, it executes a set of clearly defined tasks based on the project pom.xml configuration and the command-line options. This standard set of tasks creates the maven build lifecycle.

当我们构建Maven项目时,它将基于项目pom.xml配置和命令行选项执行一组明确定义的任务。 此标准任务集创建了Maven构建生命周期。

The benefit of a clearly defined lifestyle is that we have to remember only a few sets of commands to compile, build, install, and deploy our projects.

明确定义生活方式的好处是,我们只需要记住几组命令即可编译,构建,安装和部署我们的项目。

Recommended Reading: 20+ Maven Commands and Options (Cheat Sheet)

推荐读物 : 20多个Maven命令和选项(备忘单)

内置的构建生命周期 (Built-in Build Lifecycles)

There are three built-in build lifecycles.

有三个内置的构建生命周期。

  1. default: handles project build and deploymentdefault :处理项目的构建和部署
  2. clean: handles project cleaning清洁 :处理项目清洁
  3. site: handles the creation of project site documentationsite :处理项目站点文档的创建

Maven构建阶段 (Maven Build Phases)

Maven build lifecycle goes through a set of stages, they are called build phases. For example, the default lifecycle is made up of the following phases.

Maven构建生命周期经历了一组阶段,这些阶段称为构建阶段。 例如,默认生命周期由以下阶段组成。

  • validate验证
  • compile编译
  • test测试
  • package包
  • verify校验
  • install安装
  • deploy部署

The build phases are executed sequentially. When we run a maven build command, we specify the phase to be executed. Any maven build phases that come before the specified phase is also executed. For example, if we run mvn package then it will execute validate, compile, test, and package phases of the project.

构建阶段按顺序执行。 运行maven build命令时,我们指定要执行的阶段。 在指定阶段之前的所有Maven构建阶段也将执行。 例如,如果我们运行mvn package ,它将执行项目的验证,编译,测试和打包阶段。

Maven构建目标 (Maven Build Goals)

A build phase is made up of a set of goals. Maven goals represent a specific task that contributes to the building and managing of a project.

构建阶段由一组目标组成。 Maven目标代表一项特定的任务,有助于项目的构建和管理。

Sometimes, a maven goal is not bound to a build phase. We can execute these goals through the command line.

有时,行家目标并不局限于构建阶段。 我们可以通过命令行执行这些目标。

The syntax to execute a goal is:

执行目标的语法为:

$ mvn plugin-prefix:goal$ mvn plugin-group-id:plugin-artifact-id[:plugin-version]:goal

Here is an example to execute the dependency tree goal from the command line. It’s not part of any build phases.

这是一个从命令行执行依赖关系树目标的示例。 它不是任何构建阶段的一部分。

mvn dependency:tree

POM在构建生命周期中的作用 (Role of POM in Build Lifecycle)

The maven builds executed through the command line runs a set of phases and goals. The pom.xml configuration plays a major role in setting up the project build lifecycle.

通过命令行执行的Maven构建运行一组阶段和目标。 pom.xml配置在设置项目构建生命周期中起主要作用。

The packaging value of pom.xml file defines the set of goals to be executed by the maven build. For example, if it’s jar then the following phases and goals will be executed.

pom.xml文件的packaging值定义了maven构建要执行的目标集。 例如,如果是jar则将执行以下阶段和目标。

Phase Goal
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
目标
流程资源 资源:资源
编译 编译器:compile
流程测试资源 资源:testResources
测试编译 编译器:testCompile
测试 surefire:测试
罐子:罐子
安装 安装:安装
部署 部署:部署

We can also configure goals in the pom.xml file using the plugins element. This is mostly required when you have created a custom plugin and want to execute any specific goal for a build phase.

我们还可以使用plugins元素在pom.xml文件中配置目标。 当您创建了自定义插件并想要执行构建阶段的任何特定目标时,这通常是必需的。

参考资料 (References)

  • Apache.org DocApache.org文件

翻译自: https://www.journaldev.com/33659/maven-build-lifecycle-phases-goals

maven生命周期所有阶段

maven生命周期所有阶段_Maven构建生命周期,阶段和目标相关推荐

  1. Maven(4)--- 构建生命周期

    Maven 构建生命周期 Maven 构建生命周期定义了一个项目构建跟发布的过程. 一个典型的 Maven 构建(build)生命周期是由以下几个阶段的序列组成的: 阶段 处理 描述 验证 valid ...

  2. Maven构建生命周期和各种plugin插件

    总揽生命周期(lifecycle) 一般构建项目时执行的最常用的命领是mvn clean install,如果是IDE就是点对应的按纽其实还是调的mvn命令,除非你使用的IDE内嵌的maven(不推荐 ...

  3. Maven学习:项目构建生命周期

    图1 maven对项目构建的生命周期划分为三个阶段 可以比喻成婴儿时期,成年人时期,和老年时期. 成年人时期(default)做的事情最多,任务也基本上都处于这个阶段. 图2 Clean要干的事情如图 ...

  4. 深入理解maven构建生命周期和各种plugin插件

    鄙人的新书<Elasticsearch权威指南>正式出版发行,欢迎购买!本书由华为.中兴高级技术专家全面审读并撰序,助您挑战百万年薪 购书链接: <Elasticsearch权威指南 ...

  5. 统一过程(UP)定义了初启阶段、精化阶段、构建阶段、移交阶段和产生阶段,每个阶段以达到某个里程碑时结束,其中()的里程碑是生命周期架构。 A.初启阶段 B.精化阶段 C.构建阶段 D.移交阶段

    [最全!最详细解析!!!] 统一过程(UP)定义了初启阶段.精化阶段.构建阶段.移交阶段和产生阶段,每个阶段以达到某个里程碑时结束,其中()的里程碑是生命周期架构. A.初启阶段 B.精化阶段 C.构 ...

  6. 004_Maven构建生命周期

    1. Maven构建生命周期定义了一个项目构建跟发布的过程. 2. 一个典型的Maven构建(build)生命周期 2.1. 典型的Maven构建(build)生命周期是由以下几个阶段的序列组成的: ...

  7. gradle挂接到构建生命周期(七)

    目录 1. 概念 2. 使用gradle提供的闭包 3. 实现gradle API提供的监听器接口 1. 概念 我们知道,gradle的生命周期为 初始化阶段 => 配置阶段 => 执行阶 ...

  8. React.js 小书 Lesson18 - 挂载阶段的组件生命周期(一)

    React.js 小书 Lesson18 - 挂载阶段的组件生命周期(一) 本文作者:胡子大哈 本文原文:http://huziketang.com/books/react/lesson18 转载请注 ...

  9. sdlc 瀑布式 生命周期_SDLC指南–软件开发生命周期的阶段和方法

    sdlc 瀑布式 生命周期 When I decided to teach myself how to code almost four years ago I had never heard of, ...

最新文章

  1. C语言中字符数组初始化的几种方法
  2. 10冰点还原安装不了_荣耀智慧屏X1性能有多强?荣耀智慧屏X1怎么安装第三方软件?...
  3. memcpy和memmove的区别
  4. 发电厂电气部分第三版pdf_火力发电厂电气主接线的特点
  5. Java游戏引擎libgdx的简介
  6. Mongoose介绍和入门​​
  7. git commit报错(husky > commit-msg hook failed)
  8. 攻击者可武器化防火墙和中间系统,执行 DDoS 放大攻击
  9. 开课吧:一文读懂算法工程师大致分类与技术要求
  10. 《数学建模算法与应用》方法概述
  11. SVN客户端的安装与使用----第一章
  12. oppo的手机上如何找回原来的小米的云便签
  13. 教务系统选课(抢课)技巧
  14. opencv保存视频文件很大
  15. python 拆分excel单元格内容_Excel拆分单元格与把一个单元格内容拆分到多个单元格...
  16. Java判断上海自来水来自海上_Elasticsearch6.5.3 rest-client 用法封装
  17. RT-Thread Studio中ST-LINK下载报错“Old ST-LINK firmware version“解决
  18. 卸载Win10右下角资讯和兴趣(天气)
  19. 产品品牌想正向刷屏 就需做好精致化内容
  20. 例6-下一个更大的数

热门文章

  1. leetcode解题笔记-Summary Ranges
  2. [转载] c++的vector赋值方法汇总
  3. [转载] Python: ljust()|rjust()|center()字符串对齐
  4. [转载] Java中自定义异常的声明与处理
  5. [转载] python 一个简单的天气预报程序
  6. 3dContactPointAnnotationTool开发日志(八)
  7. vim 保存文件的回车换行模式
  8. 【转】移动Web开发-点击事件及页面滚动
  9. php读写文件要加锁
  10. java的前台与后台