Maven 插件执行的隐式 ID 是什么?
What is the implicit ID of a maven plugin execution?
要禁用由父 POM 继承的插件执行,可以按如下方式覆盖它:
<execution>
<id>TheNameOfTheRelevantExecution</id>
<phase/>
</execution>
现在如果父 POM 没有定义明确的执行 ID 怎么办? This answer 表示 "If you don't specify id for execution, Maven will do it implicitly (in a way not expected intuitively by you)." 那么 Maven 是如何生成执行 ID 的呢?链接相关 Maven 源代码的奖励积分。
注意:我不是在寻找其他方法来禁用插件执行。
默认情况下,Maven 将根据不同的情况应用以下模式创建一个执行 ID:
- 执行 ID 设置为:
default-cli
for plugin:goals 从命令行执行
- 执行 ID 设置为:
default-<goal_name>
对于 plugin:goals 作为特定包装 定义的 binding 的一部分执行
- 执行 ID 设置为:
default
作为未指定任何 ID 的 POM 的一部分执行 plugin:goals。
如果您从命令行执行 Maven Dependency Plugin,例如,使用经典的 mvn dependency:tree
目标,您会注意到 default-cli
执行 ID:
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ project ---
如果您查看任何 Maven 构建的输出以及 Maven Compiler Plugin 在编译阶段的默认执行,例如,您会注意到 default-compile
和 default-testCompile
作为Maven 编译器插件的 compile
和 testCompile
目标的执行 ID。
相同的模式适用于 Maven 执行的所有默认 plugins/goals,作为为给定包装定义的 binding 的一部分。执行 ID 始终位于相关插件和目标名称之后的圆括号中。
例如,基本 Maven 构建的摘录:
[INFO] --- maven-clean-plugin:2.5:clean (default-clean)
[INFO] --- maven-resources-plugin:2.6:resources (default-resources)
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile)
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources)
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile)
[INFO] --- maven-surefire-plugin:2.19:test (default-test)
显示执行 ID(上面代码段中的最后一个标记,括号之间)如何始终遵循此模式。
最后,如果您在没有指定 id 的情况下配置 POM 中任何插件的执行,您会注意到 Maven 应用的 default
id:
[INFO] --- exec-maven-plugin:1.1:java (default) @ project ---
来自 official Maven documentation:
命令行执行id
each mojo invoked directly from the command line will have an execution Id of default-cli assigned to it, which will allow the configuration of that execution from the POM by using this default execution Id
默认绑定执行id
each mojo bound to the build lifecycle via the default lifecycle mapping for the specified POM packaging will have an execution Id of default-goalName assigned to it
默认插件执行id
the default value of the executionId - literally set to default in the POM model - was meant to provide some of this functionality. Unfortunately, this solution was never tested to make sure it worked with the use cases above; they fell through the cracks during testing. Now, with the release of Maven 2.2.0 (and later, Maven 3.0), these use cases can finally be addressed
最后但同样重要的是,关于执行 ID,因为 Maven 3.3.1 you can even point to a particular execution id of your POM from the command line 使用新的 @executionId
运算符
要禁用由父 POM 继承的插件执行,可以按如下方式覆盖它:
<execution>
<id>TheNameOfTheRelevantExecution</id>
<phase/>
</execution>
现在如果父 POM 没有定义明确的执行 ID 怎么办? This answer 表示 "If you don't specify id for execution, Maven will do it implicitly (in a way not expected intuitively by you)." 那么 Maven 是如何生成执行 ID 的呢?链接相关 Maven 源代码的奖励积分。
注意:我不是在寻找其他方法来禁用插件执行。
默认情况下,Maven 将根据不同的情况应用以下模式创建一个执行 ID:
- 执行 ID 设置为:
default-cli
for plugin:goals 从命令行执行 - 执行 ID 设置为:
default-<goal_name>
对于 plugin:goals 作为特定包装 定义的 binding 的一部分执行
- 执行 ID 设置为:
default
作为未指定任何 ID 的 POM 的一部分执行 plugin:goals。
如果您从命令行执行 Maven Dependency Plugin,例如,使用经典的 mvn dependency:tree
目标,您会注意到 default-cli
执行 ID:
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ project ---
如果您查看任何 Maven 构建的输出以及 Maven Compiler Plugin 在编译阶段的默认执行,例如,您会注意到 default-compile
和 default-testCompile
作为Maven 编译器插件的 compile
和 testCompile
目标的执行 ID。
相同的模式适用于 Maven 执行的所有默认 plugins/goals,作为为给定包装定义的 binding 的一部分。执行 ID 始终位于相关插件和目标名称之后的圆括号中。
例如,基本 Maven 构建的摘录:
[INFO] --- maven-clean-plugin:2.5:clean (default-clean)
[INFO] --- maven-resources-plugin:2.6:resources (default-resources)
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile)
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources)
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile)
[INFO] --- maven-surefire-plugin:2.19:test (default-test)
显示执行 ID(上面代码段中的最后一个标记,括号之间)如何始终遵循此模式。
最后,如果您在没有指定 id 的情况下配置 POM 中任何插件的执行,您会注意到 Maven 应用的 default
id:
[INFO] --- exec-maven-plugin:1.1:java (default) @ project ---
来自 official Maven documentation:
命令行执行id
each mojo invoked directly from the command line will have an execution Id of default-cli assigned to it, which will allow the configuration of that execution from the POM by using this default execution Id
默认绑定执行id
each mojo bound to the build lifecycle via the default lifecycle mapping for the specified POM packaging will have an execution Id of default-goalName assigned to it
默认插件执行id
the default value of the executionId - literally set to default in the POM model - was meant to provide some of this functionality. Unfortunately, this solution was never tested to make sure it worked with the use cases above; they fell through the cracks during testing. Now, with the release of Maven 2.2.0 (and later, Maven 3.0), these use cases can finally be addressed
最后但同样重要的是,关于执行 ID,因为 Maven 3.3.1 you can even point to a particular execution id of your POM from the command line 使用新的 @executionId
运算符