【问题标题】:sonar, jacoco, and maven are not cooperating for mesonar、jacoco 和 maven 不为我合作
【发布时间】:2014-02-10 05:22:16
【问题描述】:
  • 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>

【问题讨论】:

    标签: maven-3 sonarqube jacoco


    【解决方案1】:

    您必须配置很多东西才能使 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

    【讨论】:

      猜你喜欢
      • 2013-02-07
      • 2013-03-16
      • 1970-01-01
      • 2012-06-11
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 2016-08-22
      • 2012-06-03
      相关资源
      最近更新 更多