Cobertura Maven Plugin and Sonar

285 views
Skip to first unread message

Bubunia Patra

unread,
Mar 6, 2017, 3:19:14 PM3/6/17
to Maven and Scala
Hi,

I have a issues while generating the coverage.xml in each exp target/b folders in a module A, B etc. There is a pom.xml already there in the base-directory.I have copied pom.xml and sonar-project-properties files in modules directory (like module A). The problem is only one module(A)/report/cobertura/cobertura.xml where as module(B)/report/cobertura/cobertura.xml it is not this case.

What I need to do so that the cobertura.xml gets created in all the modules(mentioned in pom.xml.  at the report/cobertura directories of each modules(exp moduleA/report/cobertura/cobertura.xml, and module B/report/cobertura/cobertura.xml etc?  Can anyone help in this regard?

Command run at the base-dir : mvn clean install pmd:pmd -DfailIfNoTests=false cobertura:cobertura -Pjenkins --projects module A,moduleB


Regards
Pradeep


base-dir
|
|-modules
| - module A
|         |-pom.xml
|         | sonar-project-properties
|-module B
|        |-pom.xml
|        |-sonar-project-properties
|
||pom.xml



<?xml version="1.0" encoding="UTF-8"?>
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-test</artifactId>
        <version>01.00.001</version>
        <name>test- ${project.artifactId}</name>
        <description>All modules</description>
        <packaging>pom</packaging>

        <modules> 
            <module>A</module>
            <module>B</module>
                <module>b1</module>
                <module>b2</module>

         </modules>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <instrumentation>
            <includes>
              <include>foo/bar/**/*.class</include>
            </includes>
          </instrumentation>
        </configuration>
    <executions>
      <execution>
        <id>clean</id>
        <phase>pre-site</phase>
        <goals>
          <goal>clean</goal>
        </goals>
      </execution>
      <execution>
        <id>instrument</id>
        <phase>site</phase>
        <goals>
          <goal>instrument</goal>
          <goal>cobertura</goal>
        </goals>
      </execution>
    </executions>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
    <!-- use mvn cobertura:cobertura to generate cobertura reports -->
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <formats>
        <format>html</format>
        <format>xml</format>
      </formats>
     </configuration>
      </plugin>
    </plugins>
  </reporting>
 
 <properties>

     <!-- Cobertura SonarQube Setup -->
                <sonar.core.codeCoveragePlugin>cobertura</sonar.core.codeCoveragePlugin>
                <sonar.java.coveragePlugin>cobertura</sonar.java.coveragePlugin>
                <sonar.junit.reportsPath>${project.basedir}/target/surefire-reports</sonar.junit.reportsPath>
                <sonar.surefire.reportsPath>${project.basedir}/target/surefire-reports</sonar.surefire.reportsPath>
                <sonar.cobertura.reportPath>${project.basedir}/target/cobertura/cobertura.ser</sonar.cobertura.reportPath>

                <!-- <sonar.cobertura.reportPath>${project.modules}/target/cobertura/cobertura.ser</sonar.cobertura.reportPath> -->

                <!-- SONAR -->
                <sonar.login>changeIt</sonar.login>
  <sonar.password>changeIt</sonar.password>
                <sonar.projectKey>cobertura-maven</sonar.projectKey>
                <sonar.projectName>CoberturaMaven</sonar.projectName>
                <sonar.projectVersion>27Jun2016</sonar.projectVersion>
                <sonar.sources>src/main/java</sonar.sources>
                <sonar.java.binaries>target/classes</sonar.java.binaries>
                <sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <sonar.language>java</sonar.language>
               

 </properties>



                
                
Reply all
Reply to author
Forward
0 new messages