我试图减少我们的Maven POM文件中的复制粘贴。
我们有一个主POM和许多从主POM继承的子项目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中(在<dependencyManagement>
或<plugins>
中),则甚至未开始打包。
是否可以共享插件配置?如何实现?
-- 在第一次得到答案后进行编辑 ---
我已经尝试了以下操作:
- 将我的XL打包插件配置放在父pom的<plugins>
元素中
- 在项目pom的<build><plugins>
元素中添加这些行:
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
</plugin>
...
</plugins>
但是它没有起作用...可能有什么问题?
-- 最后编辑 --
我想我明白了问题所在:
插件重复使用声明应该在配置文件构建中声明。
我在一个始终启用的插件中完成了这个步骤,现在它可以正常工作了。
非常感谢。