Maven在多个插件执行之间共享配置 [英] Maven share configuration between multiple plugin executions
问题描述
如果我有多个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>
我该如何重写它,以使ID1
和ID2
执行都对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屋!