end*_*ser 21 inheritance plugins maven
我正在尝试编写父pom,并且我定义了一个插件,但我需要更改所有继承实例的配置.所以,我可以在<pluginManagement>
定义中加入一些配置,我可以在其中覆盖它<plugin>
,但是如何让孩子们默认回到<pluginManagement>
版本?
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<executions...>
<configuration>
<configLocation>
(used by all children)
</configLocation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>
(unique to the parent)
</configLocation>
</configuration>
</plugin>
</plugins>
<build>
Run Code Online (Sandbox Code Playgroud)
那么,会发生什么是孩子继续显示父母的配置.
end*_*ser 14
好的,我想我有.在我的情况下,答案与你指定的内容有关 - 我确实需要标签.但是解决方案是在标签中; 通过将其绑定到非阶段,它确实执行.我知道这个.我发现的是必须匹配才能覆盖它.因此,配置永远不会被解析并且无关紧要.
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- Main declaration of the plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<!--This must be named-->
<id>checkstyle</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration...>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<!-- Uses the default config -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<!--This matches and thus overrides-->
<id>checkstyle</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
您可以在父pom中明确指定不应继承插件:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<executions...>
<configuration>
<configLocation>
(used by all children)
</configLocation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<inherited>false</inherited> <!-- Add this line -->
<configuration>
<configLocation>
(unique to the parent)
</configLocation>
</configuration>
</plugin>
</plugins>
<build>
Run Code Online (Sandbox Code Playgroud)
在你的孩子pom中,你需要指定插件(然后配置将来自<pluginManagement>
父元素.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
<build>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14635 次 |
最近记录: |