2017-08-17 99 views
1

我有一个多模块Maven项目,SonarQube v 5.6.6使用最新的JaCoCo。SonarQube + JaCoCo + TeamCity错误的模块名称

的配置如下:

<properties> 
    <sonar-maven-plugin.version>3.3.0.603</sonar-maven-plugin.version> 
    <jacoco-maven-plugin.version>0.7.9</jacoco-maven-plugin.version> 
    <sonar-jacoco-listeners.version>4.10.0.10260</sonar-jacoco-listeners.version> 
    <maven-surefire-plugin.version>2.20</maven-surefire-plugin.version> 
    <sonar.java.binaries>${basedir}</sonar.java.binaries> 
    <!--sonar properties--> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <sonar.projectName>GR</sonar.projectName> 
    <!-- Use the following property to force single language analysis, omit it to perform Multilanguage analysis --> 
    <sonar.language>java</sonar.language> 

    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> 

    <jacoco.outputDir>${project.build.directory}</jacoco.outputDir> 
    <!-- Jacoco output file for UTs --> 
    <jacoco.out.ut.file>jacoco-ut.exec</jacoco.out.ut.file> 
    <!-- Tells Sonar where the Jacoco coverage result file is located for Unit Tests --> 
    <sonar.jacoco.reportPath>${jacoco.outputDir}/${jacoco.out.ut.file}</sonar.jacoco.reportPath> 
    <!--sonar properties--> 

</properties> 

<profiles> 
    <profile> 
     <id>sonar</id> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>${maven-surefire-plugin.version}</version> 
        <configuration> 
         <argLine>${jacoco.agent.ut.arg}</argLine> 
         <properties> 
          <property> 
           <name>listener</name> 
          <value>org.sonar.java.jacoco.JUnitListener</value> 
          </property> 
         </properties> 
         <testFailureIgnore>true</testFailureIgnore> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.jacoco</groupId> 
        <artifactId>jacoco-maven-plugin</artifactId> 
        <version>${jacoco-maven-plugin.version}</version> 
        <executions> 
         <execution> 
          <id>prepare-ut-agent</id> 
          <phase>process-test-classes</phase> 
          <goals> 
           <goal>prepare-agent</goal> 
          </goals> 
          <configuration> 
           <destFile>${sonar.jacoco.reportPath}</destFile> 
           <propertyName>jacoco.agent.ut.arg</propertyName> 
           <append>true</append> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
     <dependencies> 
      <dependency> 
       <groupId>org.sonarsource.java</groupId> 
       <artifactId>sonar-jacoco-listeners</artifactId> 
       <version>${sonar-jacoco-listeners.version}</version> 
       <scope>test</scope> 
      </dependency> 
     </dependencies> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
    </profile> 
</profiles> 

问题是,当该项目是由TeamCity的建立和结果传递给SonarQube的措施覆盖率结果 - >覆盖评测 - >树是如图像,例如所有的模块名称都是相同的:项目名称+分支名称。但我希望他们有模块名称。

配置有问题吗? 谢谢!

另外,如果我使用来自官方github最简单的配置中,没有代码覆盖分析的。

Sonar Tree view

回答

1

我相信这无关的代码覆盖率和你只是迫使SonarQube所有模块由母公司pom.xml设置属性sonar.projectName有相同的名称。因此,只需将其删除或确保它为不同模块指定了不同的名称。

+0

是的,听起来很简单。刚从'pom.xml'中删除'sonar.projectName',现在显示正确。不知道,如何实现_s为不同的modules_tho指定不同的名称。 – Enigo

相关问题