title: Code coverage report from jacoco.exec file using ant
body: <p>I am trying to generate the Code coverage report from jacoco.exec file using ant.</p>
  
  <p>My ant build is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;project xmlns:jacoco="antlib:org.jacoco.ant" name="Example Ant Build with JaCoCo" default="rebuild"&gt;
  
    &lt;description&gt;
  Example Ant build file that demonstrates how a JaCoCo coverage report can be itegrated into an existing build in three simple steps.
  &lt;/description&gt;
  
    &lt;property name="src.dir" location="./java"/&gt;
    &lt;property name="result.dir" location="./target"/&gt;
    &lt;property name="result.classes.dir" location="./classes"/&gt;
    &lt;property name="result.report.dir" location="${result.dir}/site/jacoco"/&gt;
    &lt;property name="result.exec.file" location="./jacoco.exec"/&gt;
  
    &lt;!--  Step 1: Import JaCoCo Ant tasks  --&gt;
    &lt;taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"&gt;
      &lt;classpath path="./jacocoant.jar"/&gt;
    &lt;/taskdef&gt;
  
    &lt;target name="compile"&gt;
      &lt;mkdir dir="${result.classes.dir}"/&gt;
      &lt;javac srcdir="${src.dir}" destdir="${result.classes.dir}" debug="true" includeantruntime="false"/&gt;
    &lt;/target&gt;
  
    &lt;target name="test" depends="compile"&gt;
      &lt;!--
   Step 2: Wrap test execution with the JaCoCo coverage task 
  --&gt;
      &lt;jacoco:coverage destfile="${result.exec.file}"&gt;
        &lt;java classname="org.jacoco.examples.parser.Main" fork="true"&gt;
          &lt;classpath path="${result.classes.dir}"/&gt;
          &lt;arg value="2 * 3 + 4"/&gt;
          &lt;arg value="2 + 3 * 4"/&gt;
          &lt;arg value="(2 + 3) * 4"/&gt;
          &lt;arg value="2 * 2 * 2 * 2"/&gt;
          &lt;arg value="1 + 2 + 3 + 4"/&gt;
          &lt;arg value="2 * 3 + 2 * 5"/&gt;
        &lt;/java&gt;
      &lt;/jacoco:coverage&gt;
    &lt;/target&gt;
  
    &lt;target name="report" depends="test"&gt;
      &lt;!--  Step 3: Create coverage report  --&gt;
      &lt;jacoco:report&gt;
        &lt;!--
   This task needs the collected execution data and ... 
  --&gt;
        &lt;executiondata&gt;
          &lt;file file="${result.exec.file}"/&gt;
        &lt;/executiondata&gt;
        &lt;!--  the class files and optional source files ...  --&gt;
        &lt;structure name="JaCoCo Ant Example"&gt;
          &lt;classfiles&gt;
            &lt;fileset dir="${result.classes.dir}"/&gt;
          &lt;/classfiles&gt;
          &lt;sourcefiles encoding="UTF-8"&gt;
            &lt;fileset dir="${src.dir}"/&gt;
          &lt;/sourcefiles&gt;
        &lt;/structure&gt;
        &lt;!--  to produce reports in different formats.  --&gt;
        &lt;html destdir="${result.report.dir}"/&gt;
        &lt;csv destfile="${result.report.dir}/report.csv"/&gt;
        &lt;xml destfile="${result.report.dir}/report.xml"/&gt;
      &lt;/jacoco:report&gt;
    &lt;/target&gt;
  
    &lt;target name="rebuild" depends="compile,test,report"/&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>But while compiling the ant build I get the errors related to undefined symbols in the code. How do I remove them?</p>
  
  <p>An example of the error is:</p>
  
  <pre><code>compile:
  [javac] Compiling 13 source files to C:\Documents and Settings\user\Desktop\jacoco\classes
  [javac] C:\Documents and Settings\user\Desktop\jacoco\java\file.java:13: error: package org.abc.def.ghi.primitives does not exist
  [javac] import org.abc.def.ghi.primitives.Request;
  </code></pre>
  
  <p>These imports are from my code and internally defined but does ant doesn't recognize them. I have already copied all the .java and .class files.</p>
  
  <p>Any pointers will be much appreciated.</p>