<?xml version="1.0" ?>
<project name="Lengyu" xmlns:jacoco="antlib:org.jacoco.ant" default="jacoco">
<!--Jacoco-->
<property name="jacocoantPath" value="/root/files/jacocoant.jar"/>
<!--.execJacoco-->
<property name="jacocoexecPath" value="/opt/web/simba/file/jacoco.exec"/>
<!---->
<property name="reportfolderPath" value="/opt/web/simba/coverage/"/>
<!--ip-->
<property name="server_ip" value="172.27.1.216"/>
<!--jacocoagent-->
<property name="server_port" value="8893"/>
<!---->
<property name="checkOrderSrcpath" value="/opt/web/simba/src/main/java/" />
<!--.class-->
<property name="checkOrderClasspath" value="/opt/web/simba/target/classes" />
<!--antJacoco-->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocoantPath}" />
</taskdef>
<!--dump:
ip
tomcat.exec-->
<target name="dump">
<jacoco:dump address="${server_ip}" reset="false" destfile="${jacocoexecPath}"
port="${server_port}" append="true"/>
</target>
<!--jacoco:
.class
dump.exechtml-->
<target name="report">
<delete dir="${reportfolderPath}" />
<mkdir dir="${reportfolderPath}" />
<jacoco:report>
<executiondata>
<file file="${jacocoexecPath}" />
</executiondata>
<structure name="JaCoCo Report">
<group name="Check Order related">
<classfiles>
<fileset dir="${checkOrderClasspath}" />
</classfiles>
<sourcefiles encoding="utf-8">
<fileset dir="${checkOrderSrcpath}" />
</sourcefiles>
</group>
</structure>
<html destdir="${reportfolderPath}" encoding="utf-8" />
</jacoco:report>
</target>
</project>
我们运行 ant dump就会dump出exec文件,里面有覆盖率的数据。然后运行ant
report,就会根据exec生成相应的覆盖率报告。注意build.xml的配置一定要正确。尤其是exec的路径和jacoco的jar包路径,tcp服务的ip和p
ort
更多的使用方式,请参考官方文档:http://www.eclemma.org/jacoco/trunk/doc/