jacoco-maven-plugin导致网站插件在多模块项目中失败 [英] jacoco-maven-plugin causes site plugin to fail in multimodule project
问题描述
上次我决定在我的Java项目Maven版本中用 JaCoCo 插件替换 Cobertura 插件。
Last time I've decided to replace Cobertura plugin with JaCoCo plugin in my Java projects Maven builds.
其中一个是具有模块间依赖关系的多模块项目:
One of them is a multimodule project with inter-module dependencies:
*-- pl.chilldev.commons
|-- commons-concurrent
|-- commons-daemon
`-- commons-exception
问题是 commons-daemon
取决于 commons-exception
。
我有以下方式配置 jacoco-maven-plugin
:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<executions>
<execution>
<id>jacoco-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
一切正常,测试运行,但网站
目标失败:
Everything works, tests are run, but site
target fails with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project commons: failed to get report for org.apache.maven.plugins:maven-javadoc-plugin: Failed to execute goal on project commons-daemon: Could not resolve dependencies for project pl.chilldev.commons:commons-daemon:jar:0.0.3-SNAPSHOT: Could not find artifact pl.chilldev.commons:commons-exception:jar:0.0.3-SNAPSHOT -> [Help 1]
没有 jacoco-maven-plugin
即使网站
目标也一切正常。
Without jacoco-maven-plugin
everything works fine even for site
target.
推荐答案
管理到使它工作。问题是,默认情况下 prepare-agent
目标绑定到初始化
阶段,这意味着一切都将使用JaCoCo java代理执行在Maven计算之前可能无法解析类路径(我只是假设,我不知道内部)。
Managed to make it working. Problem is, that by default prepare-agent
goal binds to initialize
phase which means everything will be executing using JaCoCo java agent which probably is unable to resolve classpath before they are computed by Maven (I just assume that, I don't know internals).
添加:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
修正了它。
BTW - 这是也不需要将 report
目标添加到执行列表中,我认为将其添加到报告插件中更为正确。
BTW - It's also not needed to add report
goal into executions list, I think it's more correct to add it into reporting plugins.
这篇关于jacoco-maven-plugin导致网站插件在多模块项目中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!