Info: java version: 1.8.0_66 ant version: 1.9.6
What I want to do:
Provide a code coverage report for the server's code that is running on AWS windows 2k12 server.
What I did:
- Stop the server completely.
- Put jacocoagent.jar into server's bin folder. Note: this is inside Program Files folder
- Append -javaagent settings to JAVA_OPTS that is used during server start up.
- Start the server.
- Run my sample test from my local laptop.
- Stop the server completely. This produced a 184kb jacoco.exec.
- Copied my build.xml to the same directory where the jacoco.exec is located. C:/path/to/exec/jacoco.exec
- Copied jacocoant.jar to C:/path/to/jacocoant.jar
- cd into C:/path/to/exec/ and run command "ant"
Result:
Got error unable to read execution data file C:/path/to/exec/jacoco.exec
Build.xml:
<project name="Example" default="rebuild" xmlns:jacoco="antlib:org.jacoco.ant">
<description>
Example Ant build file that demonstrates how a JaCoCo coverage report
can be itegrated into an existing build in three simple steps.
</description>
<property name="result.dir" location="." />
<property name="result.classes.dir" location="${result.dir}/path/to/classes" />
<property name="result.report.dir" location="${result.dir}/report" />
<property name="result.exec.file" location="${result.dir}/jacoco.exec" />
<!-- Step 1: Import JaCoCo Ant tasks -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="../jacocoant.jar" />
</taskdef>
<target name="clean">
<delete dir="${result.report.dir}" />
</target>
<target name="report">
<!-- Step 3: Create coverage report -->
<jacoco:report>
<!-- This task needs the collected execution data and ... -->
<executiondata>
<file file="${result.exec.file}" />
</executiondata>
<!-- the class files and optional source files ... -->
<structure name="JaCoCo Code Coverage Report">
<classfiles>
<fileset dir="${result.classes.dir}" >
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}" />
</sourcefiles>
</structure>
<!-- to produce reports in different formats. -->
<html destdir="${result.report.dir}" />
<csv destfile="${result.report.dir}/report.csv" />
<xml destfile="${result.report.dir}/report.xml" />
</jacoco:report>
</target>
I am not sure if the problem is with exec file (it is corrupted maybe) or is with my entire setup. Any help to identify and help solving the problem is appreciated!!!
Thanks!