maven - jacoco coverage per test setup -
i'm using jacoco in order gather code metrics , import them sonarqube missing details coverage per test. after searching came this tutorial failed make work on project.
here pom.xml
<properties> <sonarversion>2.4</sonarversion> <spring-framework.version>4.0.0.release</spring-framework.version> <spring-framework.security.version>3.2.5.release</spring-framework.security.version> <jackson.version>1.9.13</jackson.version> <jacoco.version>0.7.7.201606060606</jacoco.version> <aspectj.version>1.7.4</aspectj.version> <sonar.java.coverageplugin>jacoco</sonar.java.coverageplugin> <sonar.dynamicanalysis>reusereports</sonar.dynamicanalysis> <sonar.jacoco.reportpath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportpath> <sonar.jacoco.itreportpath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.itreportpath> <sonar.jacoco.jar>${project.basedir}/libs/jacocoagent.jar</sonar.jacoco.jar> <sonar.jacoco.excludes>**/jaxb/**:**/generated/**:**/validators/**:**/dao/**:**/mbeanutils/**</sonar.jacoco.excludes> <sonar.language>java</sonar.language> <jacoco-listeners.version>2.3</jacoco-listeners.version> <jacoco.utagentconfig>-xx:-usesplitverifier -javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportpath},excludes=${sonar.jacoco.excludes}</jacoco.utagentconfig> <jacoco.itagentconfig>-javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.itreportpath},excludes=${sonar.jacoco.excludes}</jacoco.itagentconfig> </properties> <dependencies> <dependency> <groupid>javax.servlet</groupid> <artifactid>javax.servlet-api</artifactid> <version>3.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupid>javax.validation</groupid> <artifactid>validation-api</artifactid> <version>1.0.0.ga</version> </dependency> <dependency> <groupid>opendmk.java.net</groupid> <artifactid>jdmkrt</artifactid> <version>1.0-b02</version> </dependency> <dependency> <groupid>com.betfair.net.java.opendmk</groupid> <artifactid>core</artifactid> <version>1.0-b02</version> </dependency> <dependency> <groupid>commons-lang</groupid> <artifactid>commons-lang</artifactid> <version>2.6</version> </dependency> <dependency> <groupid>org.quartz-scheduler</groupid> <artifactid>quartz</artifactid> <version>2.2.2</version> <exclusions> <exclusion> <groupid>c3p0</groupid> <artifactid>c3p0</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>commons-fileupload</groupid> <artifactid>commons-fileupload</artifactid> <version>1.2</version> </dependency> <dependency> <groupid>commons-io</groupid> <artifactid>commons-io</artifactid> <version>2.1</version> </dependency> <!-- hibernate --> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-entitymanager</artifactid> <version>4.1.3.final</version> </dependency> <dependency> <groupid>org.hibernate.javax.persistence</groupid> <artifactid>hibernate-jpa-2.1-api</artifactid> <version>1.0.0.final</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-validator</artifactid> <version>4.2.0.final</version> </dependency> <dependency> <groupid>org.jboss.resteasy</groupid> <artifactid>resteasy-multipart-provider</artifactid> <version>2.3.7.final</version> <scope>provided</scope> </dependency> <dependency> <groupid>commons-net</groupid> <artifactid>commons-net</artifactid> <version>3.1</version> </dependency> <dependency> <groupid>commons-codec</groupid> <artifactid>commons-codec</artifactid> <version>1.6</version> </dependency> <dependency> <groupid>org.apache.ibatis</groupid> <artifactid>ibatis-sqlmap</artifactid> <version>2.3.0</version> </dependency> <dependency> <groupid>org.apache.httpcomponents</groupid> <artifactid>httpclient</artifactid> <version>4.3.6</version> </dependency> <dependency> <groupid>org.apache.httpcomponents</groupid> <artifactid>httpmime</artifactid> <version>4.3.6</version> </dependency> <dependency> <groupid>javax.ws.rs</groupid> <artifactid>jsr311-api</artifactid> <version>1.1</version> <scope>provided</scope> </dependency> <dependency> <groupid>org.jboss.resteasy</groupid> <artifactid>resteasy-jaxrs</artifactid> <version>3.0.5.final</version> <scope>provided</scope> </dependency> <!-- spring --> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-web</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context-support</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-tx</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-jdbc</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-orm</artifactid> <version>${spring-framework.version}</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-core</artifactid> <version>${spring-framework.security.version}</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-crypto</artifactid> <version>${spring-framework.security.version}</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-config</artifactid> <version>${spring-framework.security.version}</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-web</artifactid> <version>${spring-framework.security.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-test</artifactid> <version>${spring-framework.security.version}</version> <scope>test</scope> </dependency> <!-- log4j --> <dependency> <groupid>log4j</groupid> <artifactid>log4j</artifactid> <version>1.2.16</version> </dependency> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjrt</artifactid> <version>${aspectj.version}</version> </dependency> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjweaver</artifactid> <version>${aspectj.version}</version> </dependency> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjtools</artifactid> <version>${aspectj.version}</version> </dependency> <!-- json --> <dependency> <groupid>org.codehaus.jackson</groupid> <artifactid>jackson-mapper-asl</artifactid> <version>${jackson.version}</version> </dependency> <dependency> <groupid>org.codehaus.jackson</groupid> <artifactid>jackson-core-asl</artifactid> <version>${jackson.version}</version> </dependency> <!-- need licenseutils --> <dependency> <groupid>org.jdom</groupid> <artifactid>jdom</artifactid> <version>1.1</version> </dependency> <!-- junit --> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.12</version> <scope>test</scope> </dependency> <!-- dbunit --> <dependency> <groupid>org.dbunit</groupid> <artifactid>dbunit</artifactid> <version>2.5.1</version> </dependency> <dependency> <groupid>org.hsqldb</groupid> <artifactid>hsqldb</artifactid> <version>2.3.3</version> </dependency> <dependency> <groupid>org.mockito</groupid> <artifactid>mockito-all</artifactid> <version>1.9.5</version> </dependency> <dependency> <groupid>commons-dbcp</groupid> <artifactid>commons-dbcp</artifactid> <version>1.4</version> </dependency> <dependency> <groupid>httpunit</groupid> <artifactid>httpunit</artifactid> <version>1.7</version> </dependency> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.6</version> </dependency> <dependency> <groupid>org.codehaus.sonar-plugins.java</groupid> <artifactid>sonar-jacoco-listeners</artifactid> <version>${jacoco-listeners.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>sonar-maven-plugin</artifactid> <dependencies> <dependency> <groupid>org.codehaus.plexus</groupid> <artifactid>plexus-utils</artifactid> <version>1.1</version> </dependency> </dependencies> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.19.1</version> <configuration> <skip>true</skip> <trimstacktrace>false</trimstacktrace> </configuration> <executions> <execution> <id>unit-tests</id> <phase>test</phase> <goals> <goal>test</goal> </goals> <configuration> <argline>${jacoco.utagentconfig}</argline> <testfailureignore>true</testfailureignore> <skip>false</skip> <includes> <include>**/*test.java</include> </includes> <properties> <property> <name>listener</name> <value>org.sonar.java.jacoco.junitlistener</value> </property> </properties> </configuration> </execution> </executions> </plugin> </plugins> </build>
it runs fine if remove block :
<properties> <property> <name>listener</name> <value>org.sonar.java.jacoco.junitlistener</value> </property> </properties>
but fails block giving following error :
org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (unit-tests) on project: execution unit-tests of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: there error in forked process org.apache.maven.surefire.util.surefirereflectionexception: org.sonar.java.jacoco.jacococontroller$jacococontrollererror: unable access jacoco agent - make sure use jacoco , version not lower 0.6.2. @ org.apache.maven.surefire.util.reflectionutils.instantiateonearg(reflectionutils.java:135) @ org.apache.maven.surefire.booter.forkedbooter.createproviderincurrentclassloader(forkedbooter.java:321) @ org.apache.maven.surefire.booter.forkedbooter.invokeproviderinsameclassloader(forkedbooter.java:290) @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:242) @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:121) caused by: org.sonar.java.jacoco.jacococontroller$jacococontrollererror: unable access jacoco agent - make sure use jacoco , version not lower 0.6.2. @ org.sonar.java.jacoco.jacococontroller.<init>(jacococontroller.java:48) @ org.sonar.java.jacoco.jacococontroller.getinstance(jacococontroller.java:39) @ org.sonar.java.jacoco.junitlistener.<init>(junitlistener.java:33) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ java.lang.class.newinstance(class.java:383) @ org.apache.maven.surefire.util.reflectionutils.instantiate(reflectionutils.java:112) @ org.apache.maven.surefire.common.junit4.junit4runlistenerfactory.createcustomlisteners(junit4runlistenerfactory.java:45) @ org.apache.maven.surefire.junit4.junit4provider.<init>(junit4provider.java:110) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.apache.maven.surefire.util.reflectionutils.instantiateonearg(reflectionutils.java:131) ... 4 more caused by: java.lang.noclassdeffounderror: org/jacoco/agent/rt/rt @ org.sonar.java.jacoco.jacococontroller.<init>(jacococontroller.java:46) ... 19 more caused by: java.lang.classnotfoundexception: org.jacoco.agent.rt.rt @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:425) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:358) ... 20 more @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:224) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:153) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:145) @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:116) @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:80) @ org.apache.maven.lifecycle.internal.builder.singlethreaded.singlethreadedbuilder.build(singlethreadedbuilder.java:51) @ org.apache.maven.lifecycle.internal.lifecyclestarter.execute(lifecyclestarter.java:120) @ org.apache.maven.defaultmaven.doexecute(defaultmaven.java:355) @ org.apache.maven.defaultmaven.execute(defaultmaven.java:155) @ org.apache.maven.cli.mavencli.execute(mavencli.java:584) @ org.apache.maven.cli.mavencli.domain(mavencli.java:216) @ org.apache.maven.cli.mavencli.main(mavencli.java:160) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.codehaus.plexus.classworlds.launcher.launcher.launchenhanced(launcher.java:289) @ org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:229) @ org.codehaus.plexus.classworlds.launcher.launcher.mainwithexitcode(launcher.java:415) @ org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:356) caused by: org.apache.maven.plugin.pluginexecutionexception: execution unit-tests of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: there error in forked process org.apache.maven.surefire.util.surefirereflectionexception: org.sonar.java.jacoco.jacococontroller$jacococontrollererror: unable access jacoco agent - make sure use jacoco , version not lower 0.6.2. @ org.apache.maven.surefire.util.reflectionutils.instantiateonearg(reflectionutils.java:135) @ org.apache.maven.surefire.booter.forkedbooter.createproviderincurrentclassloader(forkedbooter.java:321) @ org.apache.maven.surefire.booter.forkedbooter.invokeproviderinsameclassloader(forkedbooter.java:290) @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:242) @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:121) caused by: org.sonar.java.jacoco.jacococontroller$jacococontrollererror: unable access jacoco agent - make sure use jacoco , version not lower 0.6.2. @ org.sonar.java.jacoco.jacococontroller.<init>(jacococontroller.java:48) @ org.sonar.java.jacoco.jacococontroller.getinstance(jacococontroller.java:39) @ org.sonar.java.jacoco.junitlistener.<init>(junitlistener.java:33) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ java.lang.class.newinstance(class.java:383) @ org.apache.maven.surefire.util.reflectionutils.instantiate(reflectionutils.java:112) @ org.apache.maven.surefire.common.junit4.junit4runlistenerfactory.createcustomlisteners(junit4runlistenerfactory.java:45) @ org.apache.maven.surefire.junit4.junit4provider.<init>(junit4provider.java:110) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.apache.maven.surefire.util.reflectionutils.instantiateonearg(reflectionutils.java:131) ... 4 more caused by: java.lang.noclassdeffounderror: org/jacoco/agent/rt/rt @ org.sonar.java.jacoco.jacococontroller.<init>(jacococontroller.java:46) ... 19 more caused by: java.lang.classnotfoundexception: org.jacoco.agent.rt.rt @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:425) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:358) ... 20 more @ org.apache.maven.plugin.defaultbuildpluginmanager.executemojo(defaultbuildpluginmanager.java:143) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:208) ... 19 more caused by: java.lang.runtimeexception: there error in forked process org.apache.maven.surefire.util.surefirereflectionexception: org.sonar.java.jacoco.jacococontroller$jacococontrollererror: unable access jacoco agent - make sure use jacoco , version not lower 0.6.2. @ org.apache.maven.surefire.util.reflectionutils.instantiateonearg(reflectionutils.java:135) @ org.apache.maven.surefire.booter.forkedbooter.createproviderincurrentclassloader(forkedbooter.java:321) @ org.apache.maven.surefire.booter.forkedbooter.invokeproviderinsameclassloader(forkedbooter.java:290) @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:242) @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:121) caused by: org.sonar.java.jacoco.jacococontroller$jacococontrollererror: unable access jacoco agent - make sure use jacoco , version not lower 0.6.2. @ org.sonar.java.jacoco.jacococontroller.<init>(jacococontroller.java:48) @ org.sonar.java.jacoco.jacococontroller.getinstance(jacococontroller.java:39) @ org.sonar.java.jacoco.junitlistener.<init>(junitlistener.java:33) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ java.lang.class.newinstance(class.java:383) @ org.apache.maven.surefire.util.reflectionutils.instantiate(reflectionutils.java:112) @ org.apache.maven.surefire.common.junit4.junit4runlistenerfactory.createcustomlisteners(junit4runlistenerfactory.java:45) @ org.apache.maven.surefire.junit4.junit4provider.<init>(junit4provider.java:110) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.apache.maven.surefire.util.reflectionutils.instantiateonearg(reflectionutils.java:131) ... 4 more caused by: java.lang.noclassdeffounderror: org/jacoco/agent/rt/rt @ org.sonar.java.jacoco.jacococontroller.<init>(jacococontroller.java:46) ... 19 more caused by: java.lang.classnotfoundexception: org.jacoco.agent.rt.rt @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:425) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:358) ... 20 more @ org.apache.maven.plugin.surefire.booterclient.forkstarter.fork(forkstarter.java:584) @ org.apache.maven.plugin.surefire.booterclient.forkstarter.fork(forkstarter.java:460) @ org.apache.maven.plugin.surefire.booterclient.forkstarter.run(forkstarter.java:229) @ org.apache.maven.plugin.surefire.booterclient.forkstarter.run(forkstarter.java:201) @ org.apache.maven.plugin.surefire.abstractsurefiremojo.executeprovider(abstractsurefiremojo.java:1026) @ org.apache.maven.plugin.surefire.abstractsurefiremojo.executeafterpreconditionschecked(abstractsurefiremojo.java:862) @ org.apache.maven.plugin.surefire.abstractsurefiremojo.execute(abstractsurefiremojo.java:755) @ org.apache.maven.plugin.defaultbuildpluginmanager.executemojo(defaultbuildpluginmanager.java:132) ... 20 more
thanks help.
add jacoco-maven-plugin
since using listener , seems missing pom. this:
<plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <version>0.7.7.201606060606</version> <executions> <execution> <id>pre-unit-test</id> <!--<phase>test</phase>--> <goals> <goal>prepare-agent</goal> </goals> <configuration> <!-- sets path file write execution data to. --> <destfile>${sonar.jacoco.reportpath}</destfile> <!-- connection surefire plugin --> <propertyname>sonarunittestargline</propertyname> </configuration> </execution> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> <configuration> <!-- sets path execution data located. --> <datafile>${sonar.jacoco.reportpath}</datafile> <!-- sets output directory code coverage report. --> <outputdirectory>${jacoco.ut.outputdir}</outputdirectory> </configuration> </execution> <execution> <id>pre-integration-test</id> <phase>pre-integration-test</phase> <goals> <goal>prepare-agent-integration</goal> </goals> <configuration> <!-- sets path file write execution data to. --> <destfile>${sonar.jacoco.itreportpath}</destfile> <!-- connection failsafe plugin --> <propertyname>sonarintegrationtestargline</propertyname> </configuration> </execution> <execution> <id>post-integration-test</id> <phase>post-integration-test</phase> <goals> <goal>report-integration</goal> </goals> <configuration> <!-- sets path execution data located. --> <datafile>${sonar.jacoco.itreportpath}</datafile> <!-- sets output directory code coverage report. --> <outputdirectory>${jacoco.it.outputdir}</outputdirectory> </configuration> </execution> <execution> <id>default-check</id> <goals> <goal>check</goal> </goals> <configuration> <datafile>${sonar.jacoco.itutcombinedreportpath}</datafile> <haltonfailure>true</haltonfailure> <rules> <!-- implementation needed maven 2 --> <rule implementation="org.jacoco.maven.ruleconfiguration"> <element>bundle</element> <limits> <!-- bump up. low 0.01 --> <limit implementation="org.jacoco.report.check.limit"> <counter>complexity</counter> <value>coveredratio</value> <minimum>0.01</minimum> </limit> </limits> </rule> </rules> </configuration> </execution> </executions> </plugin>
my properties are:
<properties> ... <!-- sonar static analysis / jacoco code coverage --> <sonar.host.url>https://sonar.domain.com/</sonar.host.url> <sonar.projectkey>${project.artifactid}</sonar.projectkey> <sonar.projectname>${project.artifactid}</sonar.projectname> <sonar.projectversion>${project.version}</sonar.projectversion> <sonar.language>java</sonar.language> <sonar.sources>src/main/java</sonar.sources> <sonar.test>target/test-classes</sonar.test> <sonar.scm.provider>git</sonar.scm.provider> <sonar.login>${sonar_login}</sonar.login> <jacoco.basedir>${project.build.directory}/code-coverage</jacoco.basedir> <!-- define location of java codecoverage data unit tests (run using surefire) --> <sonar.jacoco.reportpath>${jacoco.basedir}/jacoco-ut.exec</sonar.jacoco.reportpath> <jacoco.ut.outputdir>${jacoco.basedir}/jacoco-ut-out</jacoco.ut.outputdir> <!-- define location of java codecoverage data integration tests (run using failsafe) --> <sonar.jacoco.itreportpath>${jacoco.basedir}/jacoco-it.exec</sonar.jacoco.itreportpath> <jacoco.it.outputdir>${jacoco.basedir}/jacoco-it-out</jacoco.it.outputdir> <!-- combined report file --> <sonar.jacoco.itutcombinedreportpath>${jacoco.basedir}/jacoco-itut-combined.exec</sonar.jacoco.itutcombinedreportpath> </properties>
and record, here antrun
plugin creates itutcombined report file. warning - haven't finished testing confirm works (feedback appreciated!):
<plugin> <!--the jacoco report files need combined 1 code coverage check--> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <version>1.8</version> <executions> <execution> <phase>post-integration-test</phase> <configuration> <target> <!--<copy file="${sonar.jacoco.reportpath}" tofile="${sonar.jacoco.itutcombinedreportpath}"/>--> <concat destfile="${sonar.jacoco.itutcombinedreportpath}" append="true" binary="yes"> <filelist files="${sonar.jacoco.reportpath},${sonar.jacoco.itreportpath}"/> </concat> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
(this comes comments in first answer i'm keeping relevant answer in situations - https://stackoverflow.com/a/38177659/1019307)
Comments
Post a Comment