我正在使用一个父 POM,它定义了一个我不想在子 POM 中运行的插件。如何完全禁用子pom中的插件?
约束:我无法更改父 POM 本身。
在子 POM 中禁用 Findbugs 时,以下方法对我有用:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<executions>
<execution>
<id>ID_AS_IN_PARENT</id> <!-- id is necessary sometimes -->
<phase>none</phase>
</execution>
</executions>
</plugin>
注意:Findbugs 插件的完整定义位于我们的父/超级 POM 中,因此它将继承版本等。
在 Maven 3 中,您需要使用:
<configuration>
<skip>true</skip>
</configuration>
对于插件。
查看插件是否有“跳过”配置参数。几乎所有人都这样做。如果是,只需将其添加到子级的声明中即可:
<plugin>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
如果没有,则使用:
<plugin>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<executions>
<execution>
<id>TheNameOfTheRelevantExecution</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
该线程很旧,但也许有人仍然感兴趣。 我发现的最短形式是对 λlex 和 bmargulies 示例的进一步改进。执行标签将如下所示:
<execution>
<id>TheNameOfTheRelevantExecution</id>
<phase/>
</execution>
我想强调的2点:
发帖后发现它已经在stackoverflow中了: 在 Maven 多模块项目中,如何禁用一个子项目中的插件?
我知道这个帖子确实很旧,但 @Ivan Bondarenko 的解决方案对我的情况有所帮助。
我的
pom.xml
中有以下内容。
<build>
...
<plugins>
<plugin>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-remote-maven-plugin</artifactId>
<version>${citrus.version}</version>
<executions>
<execution>
<id>generate-citrus-war</id>
<goals>
<goal>test-war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我想要的是禁用特定配置文件的
generate-citrus-war
的执行,这就是解决方案:
<profile>
<id>it</id>
<build>
<plugins>
<plugin>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-remote-maven-plugin</artifactId>
<version>${citrus.version}</version>
<executions>
<!-- disable generating the war for this profile -->
<execution>
<id>generate-citrus-war</id>
<phase/>
</execution>
<!-- do something else -->
<execution>
...
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>