我使用了一个父 POM,它定义了一个插件,我不想在子 POM 中运行这个插件。我怎样才能完全禁用插件在儿童彩球?
约束: 无法更改父 POM 本身。
看看插件是否有一个“跳过”配置参数。几乎所有人都这样。如果有,只需将其添加到子元素的声明中:
<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>
在禁用子 POM 中的 Findbug 时,以下代码对我有效:
<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>
注意: Findbug 插件的完整定义在我们的父/super POM 中,因此它将继承版本等等。
在 Maven3中,您需要使用:
<configuration> <skip>true</skip> </configuration>
插件。
线索已经很旧了,但也许有人还是感兴趣的。 我发现的最短形式是对 λlex 和 bmargulies 的例子的进一步改进。执行标签看起来像这样:
<execution> <id>TheNameOfTheRelevantExecution</id> <phase/> </execution>
我想强调两点:
在发布之后,发现它已经处于堆栈溢出状态: 在 Maven 多模块项目中,如何在一个子项中禁用插件?
我知道这个帖子很老了,但是@Ivan Bondarenko 的解决方案帮助了我。
我的 pom.xml里有以下内容。
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执行,这就是解决方案:
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>