Java 列出 Maven 2 中所有可能的目标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3996802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 08:06:54  来源:igfitidea点击:

List all of the possible goals in Maven 2?

javamaven-2

提问by Noel M

I'm new to Maven, coming from the Ant world.

我是 Maven 的新手,来自 Ant 世界。

Is it possible to list all of the possible goals (including, say, all the plugins) that you can run?

是否可以列出您可以运行的所有可能的目标(包括所有插件)?

I can see that there used to be a -gflag in Maven 1, but this isn't available in version 2.

我可以看到-gMaven 1 中曾经有一个标志,但这在版本 2 中不可用。

采纳答案by Romain Linsolas

The goal you indicate in the command line is linked to the lifecycleof Maven. For example, the buildlifecycle (you also have the cleanand sitelifecycles which are different) is composed of the following phases:

您在命令行中指明的目标与Maven的生命周期相关联。例如,build生命周期(也有cleansite生命周期,其是不同的)由以下阶段组成:

  • validate: validate the project is correct and all necessary information is available.
  • compile: compile the source code of the project.
  • test: test the compiled source code using a suitable unit testing framework. These 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.
  • integration-test: process and deploy the package if necessary into an environment where integration tests can be run.
  • verify: run any checks to verify the package is valid and meets quality criteria
  • install: install the package into the local repository, for use as a dependency in other projects locally.
  • deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
  • validate:验证项目是否正确并且所有必要的信息都可用。
  • compile: 编译项目的源代码。
  • test:使用合适的单元测试框架测试编译的源代码。这些测试不应该要求打包或部署代码。
  • package: 将编译后的代码打包成可分发的格式,例如 JAR。
  • integration-test:如有必要,处理包并将其部署到可以运行集成测试的环境中。
  • verify:运行任何检查以验证包是否有效并符合质量标准
  • install: 安装包到本地仓库,作为本地其他项目的依赖。
  • deploy: 在集成或发布环境中完成,将最终包复制到远程存储库以与其他开发人员和项目共享。

You can find the list of "core" plugins here, but there are plenty of others plugins, such as the codehaus ones, here.

您可以在此处找到“核心”插件列表,但还有很多其他插件,例如 codehaus 插件,请点击此处

回答by Pascal Thivent

Is it possible to list all of the possible goals (including, say, all the plugins) that it is possible to run?

是否可以列出可以运行的所有可能目标(包括所有插件)?

Maven doesn't have anything built-in for that, although the list of phasesis finite (the list of plugin goalsisn't since the list of plugins isn't).

Maven 没有为此内置任何东西,尽管阶段列表是有限的(插件目标列表不是,因为插件列表不是)。

But you can make things easier and leverage the power of bash completion(using cygwin if you're under Windows) as described in the Guide to Maven 2.x auto completion using BASH(but before to choose the script from this guide, read further).

但是,您可以使事情变得更简单并利用bash 完成的强大功能 (如果您在 Windows 下使用 cygwin),如使用 BASH 的 Maven 2.x 自动完成指南中所述(但在从本指南中选择脚本之前,请进一步阅读)。

To get things working, first follow this guideto setup bash completion on your computer. Then, it's time to get a script for Maven2 and:

要使事情正常进行,请首先按照本指南在您的计算机上设置 bash 完成。然后,是时候为 Maven2 获取脚本了:

  • While you could use the one from the mini guide
  • While you use an improved version attached to MNG-3928
  • While you could use a random scripts found around the net (see the resources if you're curious)
  • I personally use the Bash Completion script from Ludovic Claude's PPA(which is bundled into the packaged version of mavenin Ubuntu) that you can downloadfrom the HEAD. It's simply the best one.

Below, here is what I get just to illustrate the result:

下面,这是我得到的只是为了说明结果:

$ mvn [tab][tab]
Display all 377 possibilities? (y or n)
ant:ant 
ant:clean 
ant:help 
antrun:help 
antrun:run 
archetype:crawl 
archetype:create 
archetype:create-from-project 
archetype:generate 
archetype:help 
assembly:assembly 
assembly:directory 
assembly:directory-single 
assembly:help 
assembly:single  
... 

Of course, I never browse the 377 possibilities, I use completion. But this gives you an idea about the size of "a" list :)

当然,我从不浏览 377 种可能性,我使用补全。但这让您了解“a”列表的大小:)

Resources

资源

回答by Denis Kniazhev

If you use IntelliJ IDEA you can browse all maven goals/tasks (including plugins) in Maven Projectstab:

如果您使用 IntelliJ IDEA,您可以在Maven Projects选项卡中浏览所有 Maven 目标/任务(包括插件):

Maven Projects

Maven项目

回答by Nash

Lets make it very simple:

让我们让它变得非常简单:

Maven Lifecycles: 1. Clean 2. Default (build) 3. Site

Maven 生命周期:1. 清理 2. 默认(构建) 3. 站点

Maven Phases of the Default Lifecycle: 1. Validate 2. Compile 3. Test 4. Package 5. Verify 6. Install 7. Deploy

默认生命周期的 Maven 阶段:1. 验证 2. 编译 3. 测试 4. 打包 5. 验证 6. 安装 7. 部署

Note: Don't mix or get confused with maven goals with maven lifecycle.

注意:不要将 Maven 目标与 Maven 生命周期混淆或混淆。

See Maven Build Lifecycle Basics1

请参阅 Maven 构建生命周期基础知识1

回答by Aguid

A Build Lifecycle is Made Up of Phases

构建生命周期由阶段组成

Each of these build lifecycles is defined by a different list of build phases, wherein a build phase represents a stage in the lifecycle.

这些构建生命周期中的每一个都由不同的构建阶段列表定义,其中构建阶段代表生命周期中的一个阶段。

For example, the default lifecycle comprises of the following phases (for a complete list of the lifecycle phases, refer to the Lifecycle Reference):

例如,默认生命周期包括以下阶段(有关生命周期阶段的完整列表,请参阅生命周期参考):

  • validate - validate the project is correct and all necessary information is available
  • compile - compile the source code of the project
  • test - test the compiled source code using a suitable unit testing framework. These 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 developers and projects.
  • 验证 - 验证项目是否正确并且所有必要的信息都可用
  • compile - 编译项目的源代码
  • 测试 - 使用合适的单元测试框架测试编译的源代码。这些测试不应该要求打包或部署代码
  • 包 - 获取编译后的代码并将其打包为其可分发格式,例如 JAR。验证 - 对集成测试的结果进行任何检查,以确保满足质量标准
  • install - 将包安装到本地存储库中,用作本地其他项目的依赖项
  • 部署 - 在构建环境中完成,将最终包复制到远程存储库以与其他开发人员和项目共享。

These lifecycle phases (plus the other lifecycle phases not shown here) are executed sequentially to complete the default lifecycle. Given the lifecycle phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, package the binaries (e.g. jar), run integration tests against that package, verify the integration tests, install the verified package to the local repository, then deploy the installed package to a remote repository.

这些生命周期阶段(以及此处未显示的其他生命周期阶段)按顺序执行以完成默认生命周期。鉴于上述生命周期阶段,这意味着当使用默认生命周期时,Maven 将首先验证项目,然后将尝试编译源代码,针对测试运行这些源代码,打包二进制文件(例如 jar),针对该项目运行集成测试包,验证集成测试,将经过验证的包安装到本地存储库,然后将安装的包部署到远程存储库。

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

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