gpt4 book ai didi

maven-2 - Maven 命令列出生命周期阶段以及绑定(bind)目标?

转载 作者:行者123 更新时间:2023-12-03 04:56:59 26 4
gpt4 key购买 nike

我刚刚学习 Maven,所以这可能是显而易见的,但我找不到一种简单的方法来列出给定项目的每个 Maven 生命周期阶段关联的目标。

我看到 Maven 默认生命周期阶段和相应的默认目标被记录在案 here 。到目前为止,我的理解是每个 pom.xml 都可以将附加目标绑定(bind)到每个生命周期阶段。

那么,是否有一个 mvn 命令来确定给定项目的每个生命周期阶段将运行的目标?如果没有,我想我只需要查看每个新的 Maven 项目的 pom.xml 即可解决这个问题?

最佳答案

buildplan-maven-plugin是一个很好的工具,用于展示目标如何与阶段绑定(bind)。

以下是您可以运行的命令示例。如果尚未安装插件,这些命令将自动下载并安装该插件。

按目标执行顺序列出目标

> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list

PLUGIN | PHASE | ID | GOAL
--------------------------------------------------------------------------------------------
maven-enforcer-plugin | validate | default | enforce
maven-dependency-plugin | process-sources | default | copy-dependencies
maven-resources-plugin | process-resources | default-resources | resources
maven-compiler-plugin | compile | default-compile | compile
maven-resources-plugin | process-test-resources | default-testResources | testResources
maven-compiler-plugin | test-compile | default-testCompile | testCompile
maven-surefire-plugin | test | default-test | test
maven-jar-plugin | package | default-jar | jar
maven-assembly-plugin | package | make-assembly | single
maven-install-plugin | install | default-install | install
maven-deploy-plugin | deploy | default-deploy | deploy

按阶段对目标进行分组

> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list-phase

validate -----------------------------------------------------------------
+ maven-enforcer-plugin | default | enforce
process-sources ----------------------------------------------------------
+ maven-dependency-plugin | default | copy-dependencies
process-resources --------------------------------------------------------
+ maven-resources-plugin | default-resources | resources
compile ------------------------------------------------------------------
+ maven-compiler-plugin | default-compile | compile
process-test-resources ---------------------------------------------------
+ maven-resources-plugin | default-testResources | testResources
test-compile -------------------------------------------------------------
+ maven-compiler-plugin | default-testCompile | testCompile
test ---------------------------------------------------------------------
+ maven-surefire-plugin | default-test | test
package ------------------------------------------------------------------
+ maven-jar-plugin | default-jar | jar
+ maven-assembly-plugin | make-assembly | single
install ------------------------------------------------------------------
+ maven-install-plugin | default-install | install
deploy -------------------------------------------------------------------
+ maven-deploy-plugin | default-deploy | deploy

按插件对目标进行分组

> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list-plugin

maven-enforcer-plugin ---------------------------------------------------
+ validate | default | enforce
maven-dependency-plugin -------------------------------------------------
+ process-sources | default | copy-dependencies
maven-resources-plugin --------------------------------------------------
+ process-resources | default-resources | resources
+ process-test-resources | default-testResources | testResources
maven-compiler-plugin ---------------------------------------------------
+ compile | default-compile | compile
+ test-compile | default-testCompile | testCompile
maven-surefire-plugin ---------------------------------------------------
+ test | default-test | test
maven-jar-plugin --------------------------------------------------------
+ package | default-jar | jar
maven-assembly-plugin ---------------------------------------------------
+ package | make-assembly | single
maven-install-plugin ----------------------------------------------------
+ install | default-install | install
maven-deploy-plugin -----------------------------------------------------
+ deploy | default-deploy | deploy

注释

默认情况下,目标会搜索用户调用 mvn deploy 时将运行的任务。 clean 之类的阶段将不包括在内。要在搜索中包含多个阶段,请使用 buildplan.tasks 属性:

> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list -Dbuildplan.tasks=clean,deploy

关于maven-2 - Maven 命令列出生命周期阶段以及绑定(bind)目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1709625/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com