声纳,jacoco和maven不合作我

时间:2014-01-20 21:09:37

标签: maven-3 sonarqube jacoco

  • Maven 3.0.4
  • sonar-maven-plugin 2.2
  • jacoco-maven-plugin 0.6.4.201312101107

当我运行mvn sonar:sonar时,jacoco-maven-plugin的prepare-agent目标无法运行,因此代理参数在需要时无法确定。

当我显式运行mvn prepare-package sonar:sonar时,我在jacoco初始化中得到无限递归。

显然我错过了什么,但是什么?

 <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <!--
                  Prepares the property pointing to the JaCoCo runtime agent which
                  is passed as VM argument when Maven the Surefire plugin is executed.
              -->
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                          <propertyName>jaCoCoSurefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

1 个答案:

答案 0 :(得分:0)

你必须配置很多东西来使jacoco工作。检查配置:

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.6.2.201302030002</version>
  <executions>
    <!-- prepare agent for measuring unit tests -->
    <execution>
      <id>prepare-unit-tests</id>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
      <configuration>
        <destFile>${sonar.jacoco.reportPath}</destFile>
      </configuration>
    </execution>
  </executions>
</plugin>

另外,您可以参考我的博客文章,了解使用单元和集成测试的多模块项目:http://www.kubrynski.com/2013/03/measuring-overall-code-coverage-in.html