挣扎于Maven父/子插件配置继承 [英] Struggling with Maven parent/child plugin configuration inheritance

查看:33
本文介绍了挣扎于Maven父/子插件配置继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写父 pom,并且定义了一个插件,但是我需要更改所有继承实例的配置.所以,我可以在 定义中放置一些配置,我可以在 中覆盖它,但是我如何让孩子们默认回到版本?

I'm trying to write a parent pom, and I have a plugin defined, but I need to change the config for all inherited instances. So, I can put some configuration in the <pluginManagement> definition, and I can override it in the <plugin>, but how do I get the children to default back to the <pluginManagement> version?

<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>

所以,发生的事情是孩子们继续显示父母的配置.

So, what happens is the children continue to show the parent's config.

推荐答案

好的,我想我知道了.就我而言,答案与您指定的内容有关 - 我确实需要标签.然而,解决方案在标签中;通过将其绑定到非阶段,它确实会执行.这是我知道的.我发现必须匹配才能覆盖.因此,配置永远不会被解析并且无关紧要.

Ok, I think I have it. The answer, in my case, relates to what you specified - I did need the tag. However the solution was in the tag; by binding it to a non-phase, it does execute. This I knew. What I discovered is that the had to match in order for it to override. Thus, the config never gets parsed and doesn't matter.

<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>

这篇关于挣扎于Maven父/子插件配置继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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