Steps to create code coverage report

-1. Download the latest Jacoco agent

-2. Add jacoco agent option to JVM

export JAVA_OPTIONS="-javaagent:/scratch/jacoco/jacoco-0.7.7/lib/jacocoagent.jar= \
destfile=/scratch/jacoco/destfile/jacoco-it.exec,
includes=oracle.*,
append=true,
classdumpdir=/scratch/jacoco/destfile/classdumpdir"

export JAVA_OPTIONS="-javaagent:/scratch/jacoco/jacoco-0.7.7/lib/jacocoagent.jar= \
destfile=/scratch/jacoco/destfile/jacoco-it.exec,
append=true,
classdumpdir=/scratch/jacoco/destfile/classdumpdir,
output=tcpserver,address=*,port=6300"

#if address=* is not working,用具体ip地址替换,like address=`hostname -i`

-3. Restart all JVM servers if output is file (file is the default value of output)

-4. Copy the jacoco.exec file to Jenkins server for publish code coverage report

-5. Ant build file example

ant dump
ant report
<project name="dump" xmlns:jacoco="antlib:org.jacoco.ant" >
    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
        <classpath path="/scratch/chichiu/jacoco/jacoco-0.8.3/lib/jacocoant.jar" />
    </taskdef>
    <target name="dump">
        <jacoco:dump address="10.229.128.229" reset="false" destfile="/scratch/chichiu/jacoco/destfile/stella.exec" port="6300" append="true"/>
    </target>
    <target name="report">
         <delete dir="/scratch/chichiu/jacoco/destfile/report" />
         <mkdir dir="/scratch/chichiu/jacoco/destfile/report" />
         <jacoco:report>
            <executiondata>
               <file file="/scratch/chichiu/jacoco/destfile/stella.exec" />
            </executiondata>
            <structure name="oscs">
                <classfiles>
                    <!--<fileset dir="/scratch/aime/jacoco/destfile/classdumpdir"/>-->
                    <!--<fileset dir="/scratch/chichiu/jacoco/destfile/classdumpdir1/" />-->
                    <fileset dir="/scratch/chichiu/jacoco/destfile/classDir/search-service/BOOT-INF/classes/search/" />
                </classfiles>
                <sourcefiles encoding="UTF-8">
                    <fileset dir="/scratch/chichiu/jacoco/destfile/src"/>
                </sourcefiles>
            </structure><html destdir="/scratch/chichiu/jacoco/destfile/report/stella.html" encoding="utf-8" />
        </jacoco:report>
    </target>    
</project>


Reference:

http://www.eclemma.org/jacoco/trunk/doc/agent.html

http://www.eclemma.org/jacoco/

http://blog.csdn.net/neven7/article/details/41789159

https://www.eclemma.org/jacoco/trunk/doc/ant.html