附加或合并默认的 maven 插件配置 [英] Append or merge default maven plugin configuration

查看:122
本文介绍了附加或合并默认的 maven 插件配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以不覆盖但合并或附加到 Apache Maven 中的默认插件配置,就像使用父 POM 配置元素一样?

Is it possible to not override but merge or append to default plugin configuration in Apache Maven just like it's possible with parent POM configuration elements?

推荐答案

我很确定我是否正确理解了您的问题:

I'm note sure if i understand your questions correctly:

例如,如果您喜欢更改已定义插件的配置,您应该知道您需要使用正确的执行 ID,该 ID 可以在日志输出中打印的默认构建期间查看(类似于这):

If you like for example to change the configuration of an already defined plugin you should be aware that you need to use the correct execution id which can be looked at during a default build which is printed out in the log output (something like this):

[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) @ parent ---
[INFO]

大括号中的值给出了提示:default-clean 现在可用于向配置添加信息或更改行为:

The value in braces gives the hint: default-clean can now be used to add information to the configuration or also to change behaviour:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <executions>
      <execution>
        <id>default-clean</id>
        <configuration>
         <.. combine.children="append">
         </...>
        </configuration>

查看以下更多解释.

如果需要,您可以这样做.假设您在父 pom 文件中定义了以下内容:

You can do this if you need. Lets say you have defined the following in a parent pom file:

<plugin>
 <groupId>..</groupId>
 <artifactId>..</artifactId>
 <configuration>
   <values>
     <value>First</value>
   </values>
 </configuration>
</plugin>

在继承的 pom 文件中,您现在可以编写以下内容:

In an inheriting pom file you can now write the following:

<plugin>
 <groupId>..</groupId>
 <artifactId>..</artifactId>
 <configuration>
   <values combine.children="append">
     <value>Second</value>
   </values>
 </configuration>
</plugin>

或者如果你做一些不同的事情:

Or if you do something different:

<plugin>
 <groupId>..</groupId>
 <artifactId>..</artifactId>
 <configuration>
   <values combine.children="override">
     <value>Second</value>
   </values>
 </configuration>
</plugin>

或者您可以明确给出已经是默认值的内容:

or you can give explicitly what is already the default:

<plugin>
 <groupId>..</groupId>
 <artifactId>..</artifactId>
 <configuration>
   <values combine.children="merge">
     <value>Second</value>
   </values>
 </configuration>
</plugin>

这是记录在 pom 参考中.

这篇关于附加或合并默认的 maven 插件配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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