linux环境中设置jacoco覆盖率
Posted 梦想空间
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux环境中设置jacoco覆盖率相关的知识,希望对你有一定的参考价值。
cd /alidata1/admin/za-themis pkill -9 -f za-themis #CATALINA_HOME=/root/za-tomcat #CATALINA_BASE=/root/za-tomcat export JAVA_OPTS="-server -Xms2g -Xmx2g -XX:NewSize=1g -XX:MaxNewSize=1g -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:CMSFullGCsBeforeCompaction=5 -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:+DisableExplicitGC -XX:+UseCompressedOops -XX:+DoEscapeAnalysis -XX:MaxTenuringThreshold=10 -Dhsf.http.enable=true -Dhsf.server.ip=10.253.104.74 -Dpandora.qos.port=8081 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=7092 -Djava.rmi.server.hostname=10.253.104.74 -javaagent:./jacoco-0.8.0/lib/jacocoagent.jar=includes=*,output=tcpserver,port=17297,address=10.253.104.74 -Dhsf.server.port=8082 -Dhsf.http.port=8083 -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8184 -Dproject.name=za-themis " ./bin/startup.sh tail ./logs/catalina.out
ant build.xml文件:
<?xml version="1.0"?>
-<project default="jacoco" xmlns:jacoco="antlib:org.jacoco.ant" name="PPAUTO">
<!--Jacoco的安装路径-->
<property name="jacocoantPath" value="./jacoco-0.8.0/lib/jacocoant.jar"/>
<!--最终生成.exec文件的路径,Jacoco就是根据这个文件生成最终的报告的-->
<property name="jacocoexecPath" value="./jacoco.exec"/>
<!--生成覆盖率报告的路径-->
<property name="reportfolderPath" value="./report/"/>
<!--远程tomcat服务的ip地址-->
<property name="server_ip" value="10.253.104.74"/>
<!--前面配置的远程tomcat服务打开的端口,要跟上面配置的一样-->
<property name="server_port" value="17297"/>
<!--za-themis.源代码路径-->
<property name="za-themispath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis/"/>
<property name="za-themisbizpath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-biz/"/>
<property name="za-themiscommonpath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-common/"/>
<property name="za-themisenginepath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-engine/"/>
<property name="za-themisdaopath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-dao/"/>
<!--za-themis.class文件路径-->
<property name="za-themisClasspath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis/target/classes/com/zhongan/themis"/>
<property name="za-themisbizClasspath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-biz/target/classes/com/zhongan/themis"/>
<property name="za-themiscommonClasspath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-common/target/classes/com/zhongan/themis"/>
<property name="za-themisdaoClasspath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-dao/target/classes/com/zhongan/themis"/>
<property name="za-themisengineClasspath" value="/root/.jenkins/workspace/za-qa-jacocoThemis/za-themis-engine/target/classes/com/zhongan/themis"/>
<!--让ant知道去哪儿找Jacoco-->
-<taskdef resource="org/jacoco/ant/antlib.xml" uri="antlib:org.jacoco.ant">
<classpath path="${jacocoantPath}"/>
</taskdef>
<!--dump任务: 根据前面配置的ip地址,和端口号, 访问目标tomcat服务,并生成.exec文件。-->
-<target name="dump">
<jacoco:dump append="true" port="${server_port}" destfile="${jacocoexecPath}" reset="false" address="${server_ip}"/>
</target>
<!--jacoco任务: 根据前面配置的源代码路径和.class文件路径, 根据dump后,生成的.exec文件,生成最终的html覆盖率报告。-->
-<target name="report">
<delete dir="${reportfolderPath}"/>
<mkdir dir="${reportfolderPath}"/>
-<jacoco:report>
-<executiondata>
<file file="${jacocoexecPath}"/>
</executiondata>
-<structure name="JaCoCo Report">
-<group name="za-themis">
-<classfiles>
<fileset dir="${za-themisClasspath}"/>
</classfiles>
-<sourcefiles encoding="utf-8">
<fileset dir="${za-themispath}"/>
</sourcefiles>
</group>
-<group name="za-themis-biz">
-<classfiles>
<fileset dir="${za-themisbizClasspath}"/>
</classfiles>
-<sourcefiles encoding="utf-8">
<fileset dir="${za-themisbizpath}"/>
</sourcefiles>
</group>
-<group name="za-themis-common">
-<classfiles>
<fileset dir="${za-themiscommonClasspath}"/>
</classfiles>
-<sourcefiles encoding="utf-8">
<fileset dir="${za-themiscommonpath}"/>
</sourcefiles>
</group>
-<group name="za-themis-engine">
-<classfiles>
<fileset dir="${za-themisengineClasspath}"/>
</classfiles>
-<sourcefiles encoding="utf-8">
<fileset dir="${za-themisenginepath}"/>
</sourcefiles>
</group>
-<group name="za-themis-dao">
-<classfiles>
<fileset dir="${za-themisdaoClasspath}"/>
</classfiles>
-<sourcefiles encoding="utf-8">
<fileset dir="${za-themisdaopath}"/>
</sourcefiles>
</group>
</structure>
<html encoding="utf-8" destdir="${reportfolderPath}"/>
</jacoco:report>
</target>
</project>
以上是关于linux环境中设置jacoco覆盖率的主要内容,如果未能解决你的问题,请参考以下文章