ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

java – maven插件执行的隐式ID是什么?

2019-09-26 08:00:43  阅读:292  来源: 互联网

标签:java maven pom-xml


要禁用父POM继承的插件执行,可以按如下方式覆盖它:

<execution>
    <id>TheNameOfTheRelevantExecution</id>
    <phase/>
</execution>

现在如果父POM没有定义显式执行ID怎么办? This answer说“如果你没有指定id来执行,Maven将隐式地执行它(以你不直观的方式).”那么Maven如何生成执行ID?用于链接相关Maven源代码的加分点.

注意:我不是在寻找禁用插件执行的替代方法.

解决方法:

默认情况下,Maven将根据不同的情况创建应用以下模式的执行ID:

>执行ID设置为:default-cli for plugin:从命令行执行的目标
>执行ID设置为:default-< goal_name> for plugin:作为特定包装定义的binding的一部分执行的目标
>执行ID设置为:插件的默认值:目标执行作为POM的一部分,没有指定任何ID.

例如,如果从命令行执行Maven Dependency Plugin,使用经典的mvn依赖关系:树目标,您将注意到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执行的所有默认插件/目标,作为为给定包装定义的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(上面代码段中的最后一个标记,括号之间)是如何始终遵循此模式的.

最后,如果您在POM中配置任何插件的执行而未指定id,您将注意到Maven应用的默认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起,您甚至可以使用新的@executionId运算符指向POM from the command line的特定执行ID

标签:java,maven,pom-xml
来源: https://codeday.me/bug/20190926/1819362.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有