Skip to content

Commit 9b08e4b

Browse files
committed
Build: Guard JaCoCo taskdef behind availability check (F-2151)
1 parent 7a5ac24 commit 9b08e4b

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

build.xml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@
9393
</not>
9494
</condition>
9595

96-
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
97-
<classpath path="${env.JACOCO_HOME}/jacocoant.jar"/>
98-
</taskdef>
96+
<!-- Check if JaCoCo is available -->
97+
<condition property="jacoco.available">
98+
<and>
99+
<isset property="env.JACOCO_HOME"/>
100+
<available file="${env.JACOCO_HOME}/jacocoant.jar"/>
101+
</and>
102+
</condition>
99103

100104
<!-- classpath to compiled wolfssl.jar, for running tests -->
101105
<path id="classpath">
@@ -430,7 +434,16 @@
430434
</junit>
431435
</target>
432436

433-
<target name="test-jacoco" depends="build-test">
437+
<target name="jacoco-taskdef" if="jacoco.available">
438+
<taskdef uri="antlib:org.jacoco.ant"
439+
resource="org/jacoco/ant/antlib.xml">
440+
<classpath path="${env.JACOCO_HOME}/jacocoant.jar"/>
441+
</taskdef>
442+
</target>
443+
444+
<target name="test-jacoco"
445+
depends="build-test, jacoco-taskdef"
446+
if="jacoco.available">
434447
<jacoco:coverage destfile="${build.dir}/jacoco.exec">
435448
<junit printsummary="yes" showoutput="yes" haltonfailure="yes" fork="true">
436449
<classpath>
@@ -460,7 +473,9 @@
460473
</jacoco:coverage>
461474
</target>
462475

463-
<target name="coverage-report">
476+
<target name="coverage-report"
477+
depends="jacoco-taskdef"
478+
if="jacoco.available">
464479
<jacoco:report>
465480
<executiondata>
466481
<file file="${build.dir}/jacoco.exec"/>

0 commit comments

Comments
 (0)