maven如何为相同的执行id创建有效的插件配置?



我在我的项目中有以下插件配置:

<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<includes>
<include>AA</include>
</includes>
</configuration>
<executions>
<execution>
<id>the_same_id</id>
<phase>process-test-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

和以下插件配置在我的父pom:

<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<lineEnding>LF</lineEnding>
<includes>
<include>A</include>
<include>B</include>
<include>C</include>
</includes>
</configuration>
<executions>
<execution>
<id>the_same_id</id>
<phase>process-sources</phase>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
</plugin>

当我运行mvn help: effective:pom这是我的插件的合并配置:

<plugins>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>the_same_id</id>
<phase>process-test-classes</phase>
<goals>
<goal>check</goal>
<goal>sort</goal>
</goals>
<configuration>
<includes>
<include>AA</include>
</includes>
<lineEnding>LF</lineEnding>
</configuration>
</execution>
</executions>
<configuration>
<includes>
<include>AA</include>
</includes>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>

根据这个插件配置的默认合并行为:

是根据元素名合并配置元素的内容。

中显示的包含

部分,因为它只包含来自项目组合而不包含来自父组合的组合。然而,按照这个逻辑,我不明白为什么effective-pom配置包含两个目标,而不是项目配置中的一个目标。

EDIT: Itis在POM参考,插件部分中有适当的文档记录。谢谢卡尔指出这一点!

在负责合并的代码库中,每个属性都略有不同。

如果你的目标没有被排除在外,那么这些目标将被合并在一起。

同样,你的配置也可能以不同的方式合并,考虑到插件的生命周期配置。

最新更新