Maven在多个插件执行之间共享配置 [英] Maven share configuration between multiple plugin executions

查看:145
本文介绍了Maven在多个插件执行之间共享配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有多个Maven插件执行,并且它们共享至少一个相同的配置值,那么有没有办法让我在插件的所有执行之间共享此配置.

If I have multiple executions of a Maven plugin and they share at least one of the same configuration values, is there a way for me to share this configuration between all executions of the plugin.

考虑具有两次执行的构建插件的琐碎情况:

Consider the trivial case of a build plugin with two executions:

<plugin>
    <!-- ID, version... -->
    <executions>
        <execution>
            <id>ID1</id>
            <configuration>
                <myConfig>foo</myConfig>
                ...
            </configuration>
        </execution>
        <execution>
            <id>ID2</id>
            <configuration>
                <myConfig>foo</myConfig>
                ...
            </configuration>
        </execution>
    </executions>
</plugin>

我该如何重写它,以使ID1ID2执行都对myConfig配置使用相同的值?

How can I rewrite this so that both the ID1 and the ID2 executions use the same value for the myConfig configuration?

推荐答案

为什么不将通用配置移出具体执行?

Why not move common configuration outside concrete executions?

<plugin>
    <!-- ID, version... -->
    <configuration>
        <commonConfig>foo</commonConfig>
    </configuration>
    <executions>
        <execution>
            <id>ID1</id>
            <configuration>
                <specificConfig>bar</specificConfig>
            </configuration>
        </execution>
        <execution>
            <id>ID1</id>
            <configuration>
                <specificConfig>baz</specificConfig>
            </configuration>
        </execution>
    </executions>
</plugin>

它适用于我使用的某些插件(例如gmaven-plugin)和 Maven文档我没有发现任何证据不起作用.

It works for some plugins I use (e.g. gmaven-plugin) and in Maven documentation I haven't found any evidence it shouldn't work.

这篇关于Maven在多个插件执行之间共享配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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