I need to configure JaCoCo code coverage in Jenkins using Sonar.
I made the following entries in the sonar-project.properties file
sonar.projectKey=projectX:projectX sonar.projectName=projectX sonar.projectVersion=1.0 sources=src tests=test binaries=workspace/stage/main/classes,workspace/stage/test/classes libraries=workspace/stage/artifact/lib/*.jar sonar.dynamicAnalysis=reuseReports sonar.core.codeCoveragePlugin=jacoco sonar.jacoco.reportPath=reports/jacoco.exec
I also wrote the following ant tasks:
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"> </taskdef> <target name="jacoco-coverage"> <jacoco:coverage enabled="true" destfile="jacoco.exec"> <junit fork="true" forkmode="once" includeAntRuntime="true" maxmemory="512M" printsummary="withOutAndErr" haltonfailure="false"> <test name="com.test.HelloWorld"/> <batchtest todir="workspace/stage/test/classes/"> <fileset dir="../test" includes="**/*.java"/> </batchtest> <classpath> <path refid="classpath.test"/> <pathelement location="workspace/stage/test/classes/" /> </classpath> </junit> </jacoco:coverage> </target> <target name="jacoco-report"> <jacoco:report> <executiondata> <file file="jacoco.exec" /> </executiondata> <structure name="Example Project"> <classfiles> <fileset dir="workspace/stage/test/classes" /> </classfiles> <sourcefiles encoding="UTF-8"> <fileset dir="test" /> </sourcefiles> </structure> <html destdir="report" /> </jacoco:report> </target>
The jacoco.exec file is not generated from "jacoco-coverage", so the target of "jacoco-report" fails.
Any input pointer will be appreciated.
Thanks in advance.
source share