Maven:生命周期,阶段,插件,目标 [英] Maven: Lifecycle vs. Phase vs. Plugin vs. Goal

查看:116
本文介绍了Maven:生命周期,阶段,插件,目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相对较新的开发人员,尽管我已经使用了一段时间,但我还是希望巩固我的Maven基础.我的问题的部分原因是我对蚂蚁没有没有的经验,这似乎来自于许多解释.我一直在阅读和观看教程,并且不断听到相同的用语:

Relatively new developer here, even though I've been using it for a little while, I'm hoping to solidify my Maven fundamentals. Part of my problem is that I have no experience with Ant, which seems to be from where many explanations stem. I've been reading and watching tutorials, and I keep hearing the same terms:

  • 生命周期
  • 阶段
  • 插件
  • 目标

据我了解,生命周期似乎是最广泛的,并且由阶段,插件和/或目标组成(或由阶段,插件或目标完成).

From what I've learned, it seems that lifecycle is the broadest of the bunch, and is composed of (or completed by) phases, plugins, and/or goals.

问题:您能否提供有关这些术语如何关联以及最常见的示例的任何信息?

Question: Could you provide any info on how these terms are related and the most common examples?

越明确越基本,那就越好!

The more explicit and basic, the better!

推荐答案

Maven生命周期是一个(抽象的)概念,涵盖了所有步骤(或更好的是: Maven设计师决定支持的步骤)预计将在项目的开发生命周期中发生.这些步骤(或阶段)在下文中被称为阶段 Maven术语.

A Maven lifecycle is an (abstract) concept that covers all steps (or better: all the steps the Maven designers decided to support) that are expected to occur in a project's development lifetime. These steps (or stages) are called phases in Maven terminology.

Maven插件目标的容器/供应商.目标中实现的代码才是真正的主力军. ( Maven本身只是管理插件和执行目标.). 每个插件的目标都可以分配/绑定到任何生命周期阶段.

A Maven plugin is a container for/supplier of goals. Code implemented in goals is the real workhorse. (Maven in its core itself is just managing plugins and executing goals). Each of a plugin's goals can be assigned/bound to any of the lifecycle phases.

调用mvn <phase> Maven遍历所有阶段(每次)并执行所有已绑定到任何目标的目标(由插件提供)阶段,直到(包括)给定阶段.如果有一个阶段,目标没有约束,那么什么也做不了.但是该阶段还是通过了.

When invoking mvn <phase> Maven passes all phases (every time) and executes all goals (supplied by plugins) that have been bound to any of the phases prior and up to (and including) the given phase. If there is a phase with no goal bound to it nothing is done. But the phase is passed nevertheless.

即您不能'插入'其他阶段" 进入Maven的内置生命周期之一.他们已经在那里,总是!您可以按照自己的阶段来开发自己的生命周期,但这远不止是简单地使用Maven.

I.e. you can't "'insert' additional phases" into one of Maven's built-in lifecycles. They are already there, always! You could develop your own lifecycle with its own phases but that's far beyond simply using Maven as it is.

称为预安装" 后包装" 的阶段不存在.

参考文献:

如果您想知道Maven如何知道在POM中没有任何目标绑定的情况下,有一个链接到

If you ever wondered how Maven knows what to do without any goal binding in the POM there's a link to default-bindings.xml at the end which is located in <Your Maven installation>/lib/maven-core-x.y.z.jar/META-INF/plexus/default-bindings.xml.

内置生命周期的各个阶段( clean 默认站点)在

The phases for the built-in lifecycles (clean, default, site) are declared in <Your Maven installation>/lib/maven-core-x.y.z.jar/META-INF/plexus/components.xml under .../<component>/<role>org.apache.maven.lifecycle.Lifecycle.

Maven:完整参考,第4章.构建生命周期

通过示例进行的Maven, 3.5.核心概念

这篇关于Maven:生命周期,阶段,插件,目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆