-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathjenkins-build.xml
60 lines (52 loc) · 2.63 KB
/
jenkins-build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="UTF-8"?>
<project name="JacocoDemo" xmlns:jacoco="antlib:org.jacoco.ant" default="jacoco">
<property name="reportfolderPath" value="${WORKSPACE}/jacoco-report"/>
<!--.class 文件路径-->
<property name="checkOrderClasspath" value="${WORKSPACE}/target/classes" />
<!--源代码路径-->
<property name="checkOrderSrcPath" value="${WORKSPACE}/src/main/java" />
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocoantPath}" />
</taskdef>
<!--让 ant 知道去哪儿找 Jacoco-->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocoantPath}" />
</taskdef>
<!--dump 任务: 根据前面配置的 ip 地址,和端口号,访问目标 Tomcat 服务,并生成 .exec 文件。-->
<!-- reset="true"是指在dump完成之后,重置jvm中的覆盖率数据为空。append="true"是指dump出来的exec文件为增量方式 -->
<target name="dump">
<jacoco:dump address="${server_ip}" reset="${reset}" destfile="${jacocoexecPath}" port="${server_port}" append="${append}"/>
</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="Check Order related">
<classfiles>
<fileset dir="${checkOrderClasspath}">
<!-- 过滤不必要的文件 -->
<exclude name="**/R.class"/>
<exclude name="**/R$*.class"/>
<exclude name="**/*$ViewInjector*.*"/>
<exclude name="**/BuildConfig.*"/>
<exclude name="**/Manifest*.*"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${checkOrderSrcPath}" />
</sourcefiles>
</group>
</structure>
<html destdir="${reportfolderPath}" encoding="UTF-8" />
<csv destfile="${reportfolderPath}/coverage-report.csv" encoding="UTF-8"/>
<xml destfile="${reportfolderPath}/coverage-report.xml" encoding="UTF-8"/>
</jacoco:report>
</target>
</project>