那里
我有一个父pom.xml,它定义了maven-ear-plugin的默认配置。
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<modules>
<jarModule>
<groupId>com.test</groupId>
<artifactId>artifact1</artifactId>
</jarModule>
<jarModule>
<groupId>com.test</groupId>
<artifactId>artifact2</artifactId>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>在子pom中,我在<plugins>部分定义了maven-ear-plugin。
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<executions>
<execution>
<id>default-ear</id>
<phase>package</phase>
<goals>
<goal>ear</goal>
</goals>
<configuration>
<earSourceDirectory>EarContent</earSourceDirectory>
<defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
<modules>
<jarModule>
<groupId>com.test</groupId>
<artifactId>artifact3</artifactId>
</jarModule>
</modules>
</configuration>
</execution>
</executions>
</plugin>我的意图是在ear中包含所有3个jar文件-- artifact1、artifact2和artifact3。但是,在构建之后,只包含在子artifact3中定义的pom.xml。因此,在默认情况下,子<modules>中的pom.xml定义会覆盖父pom中定义的内容,而不是合并。实际上,如果我删除子<modules>中的整个pom.xml部分,则在构建之后将包含artifact1和artifact2。
我的问题是是否有一种方法包括在父pom和子pom中定义的所有jar模块。我有几个ear项目,它们都需要包含相同的jar模块集,加上自己的几个jar模块。我正在尝试将一组常见的jar模块移动到父程序中,这样它们就不会在每个子pom.xml中重复。
更新以澄清我的项目关系:
parent pom.xml (define maven-ear-plugin in the pluginManagement section)
-- project1 pom.xml (multi-module project)
-- myJar-proj1
-- myWeb-proj1
-- myEar-proj1 (define maven-ear-plugin in the <build> section)
-- project2 pom.xml (multi-module project)
-- myJar-proj2
-- myWeb-proj2
-- myEar-proj2 (define maven-ear-plugin in the <build> section)发布于 2013-08-07 21:39:58
为了实现合并行为,应该将maven-ear-plugin plugins标记放在父pom (而不是pluginManagement)中。
亲本pom
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<modules>
<jarModule>
<groupId>com.test</groupId>
<artifactId>artifact1</artifactId>
</jarModule>
<jarModule>
<groupId>com.test</groupId>
<artifactId>artifact2</artifactId>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>编辑
在OP澄清的projects结构之后:在子项目中,modules元素上的属性modules:
<modules combine.children="append">
<jarModule>
<groupId>com.test</groupId>
<artifactId>artifact3</artifactId>
</jarModule>
</modules>父程序仍然应该只在pluginManagement中定义插件。
https://stackoverflow.com/questions/18113739
复制相似问题