1. 程式人生 > >linux環境中設置jacoco覆蓋率

linux環境中設置jacoco覆蓋率

nal tom 技術分享 pac pil maxperm XP analysis app

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覆蓋率