Maven多模块和插件调用

时间:2014-04-03 16:14:22

标签: maven maven-plugin multi-module maven-module

我的多模块项目具有以下结构:

parent
module 1 <-- inherits from parent via <relativePath>../parent/pom.xml</relativePath>
module 2 <-- inherits from parent via <relativePath>../parent/pom.xml</relativePath>
aggregator <-- aggregates modules with <modules><module>

聚合器调用以下插件:

<build>
<plugins>
    <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>jacoco-initialize</id>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
                <configuration>
                    <destFile>some path</destFile>
                </configuration>
            </execution>
        </executions>
        <configuration>
            <append>true</append>
        </configuration>
    </plugin>
</plugins>
</build>

为聚合器调用插件,但我想为所有模块(1和2)调用它。

我知道我可以更改父pom,但我希望保持干净(这种更改是更大实现的一部分)。

是否有可能以这样的方式配置插件,它调用所有模块(就像放在父pom中一样)?

1 个答案:

答案 0 :(得分:0)

简而言之:否。

模块在未在其自己的POM中定义的生命周期中获取插件的唯一方法是从其父级继承配置。

您应该考虑将父项和聚合器合并到一个项目中,即将aggegrator也作为父项。这样更干净。

相关问题