【发布时间】:2011-05-07 22:39:17
【问题描述】:
我正在尝试减少 maven pom 文件中的复制/粘贴。
我们有一个 master pom 和许多从 master 继承的子项目 pom。
我想分享一个复杂的插件定义,如下所示:
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<configuration>
<!-- many xml lines here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
<goal>generate-daemons</goal>
<goal>create-repository</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo.appassembler</groupId>
<artifactId>appassembler-booter</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
当这个插件定义在项目pom中时,打包就做好了。
当定义被移动到父 pom(in 或 in )时,甚至没有开始打包。
是否可以共享插件配置?怎么样?
-- 在第一个答案后编辑---
我尝试了以下方法:
- 将我的 XL 打包插件配置放在我的父 pom 的元素中
- 在我的项目 pom 元素中添加以下行:
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
</plugin>
...
</plugins>
但它不起作用... 这有什么问题?
-- 最后一次编辑--
我想我明白了问题所在:
插件重用声明应在配置文件构建中声明。
我在一个始终启用的插件中做到了这一点,现在它工作正常。
非常感谢。
【问题讨论】: