java - Integration sonar with jacoco. I see exluded packages in sonar coverage report -
i want migrate cobertura jacoco codecoverage tool. i'm using maven build tool , added jococo-maven-plugin in pom.xml file. configuration looks this:
<plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <version>0.7.2.201409121644</version> <configuration> <append>true</append> <outputencoding>utf-8</outputencoding> <destfile>${sonar.jacoco.reportpath}</destfile> <datafile>${sonar.jacoco.reportpath}</datafile> <outputdirectory>${jacoco.output.path}</outputdirectory> <excludes> <exclude>com/acmecorp/acmeproject/mbean/**/*.class</exclude> <exclude>com/acmecorp/acmeproject/model/**/*.class</exclude> </excludes> </configuration> <executions> <execution> <id>agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-site</id> <phase>package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>
so after performing mvn clean install
jacoco generates me pretty html pages code coverage. , document looks how want look.
the second step need perform integrate jococo sonar. integrated sonar cobertura. removed cobertura specific properties , added properties related jococo.
<properties> <!--<sonar.cobertura.reportpath>target/site/cobertura/coverage.xml</sonar.cobertura.reportpath>--> <sonar.java.coverageplugin>jacoco</sonar.java.coverageplugin> <sonar.projectkey>${project.artifactid}</sonar.projectkey> <sonar.projectname>acme project</sonar.projectname> <sonar.projectversion>${project.version}</sonar.projectversion> <sonar.java.source>${java.compliance.level}</sonar.java.source> <sonar.sources>src/main/java</sonar.sources> <sonar.jdbc.url>jdbc:mysql://4.4.8.8:3306/sonar?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true&useconfigs=maxperformance</sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.driver</sonar.jdbc.driver> <sonar.jdbc.username>ranos</sonar.jdbc.username> <sonar.jdbc.password>ranos</sonar.jdbc.password> <sonar.host.url>http://4.4.8.8:9000/sonar/</sonar.host.url> <sonar.jacoco.reportpath>target/sites/jacoco/jacoco.exec</sonar.jacoco.reportpath> <jacoco.output.path>target/sites/jacoco/</jacoco.output.path> </properties>
maven plugin
<plugin> <groupid>org.sonarsource.scanner.maven</groupid> <artifactid>sonar-maven-plugin</artifactid> <version>3.0.1</version> </plugin>
and profile
<profiles> <profile> <id>sonar</id> <activation> <activebydefault>true</activebydefault> </activation> </profile> </profiles>
as result such code coverage on server:
and see in generated coverage report on server see excluded packages included in report. when use cobertura worked fine.
so may me this. not want add exclusions sonar configuration. hope additional configuration jococo plugin.
update
in case use cobertura maven-plugin sonar (i mean if comment line <sonar.jacoco.reportpath>target/sites/jacoco/jacoco.exec</sonar.jacoco.reportpath>
, uncomment 1 <sonar.cobertura.reportpath>target/site/cobertura/coverage.xml</sonar.cobertura.reportpath>
)
the exclusions need happen not on jacoco side, on sonarqube side, , specified via sonarqube ui, rather in pom.
the docs give details: http://docs.sonarqube.org/display/sonar/narrowing+the+focus#narrowingthefocus-ignorecodecoverage
Comments
Post a Comment