views:

391

answers:

1

I tried to get Cobertura running inside my ant script, but I'm stuck right at the beginning. When I try to insert the cobertura taskdef I'm missing the Log4J libraries.

Ant properties & classpath

<property name="cobertura.dir" location="/full/path/to/cobertura-1.9.3" />
<path id="cobertura.classpath">
 <fileset dir="${cobertura.dir}">
  <include name="cobertura.jar" />
  <include name="lib/**/*.jar" />
 </fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />

My ant target

<!-- ================================= 
      target: cobertura              
     ================================= -->
<target name="cobertura" depends="clean, init" description="Generates cobertura coverage reports">
 <cobertura-instrument todir="${dir.build.instrumented}">
  <fileset dir="${dir.build}">
   <include name="**/*.class" />
  </fileset>
 </cobertura-instrument>
</target>

I think I did everything like it is described in the Cobertura documentation but I get this

Ant build error

BUILD FAILED
build.xml:95: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

Inside the ${cobertura.dir} there is the lib directory with all files. I unzipped it from the cobertura distribution ZIP directly into that directory.

Am I missing a step? Something wrong with my configuration so far?

A: 

I just upgraded to the latest cobertura and mine works fine. Is it possible that something else is on the CLASSPATH with a different version of log4j so it is picking up wrong one?

TofuBeer
Hm, I just tried to build it outside of my Eclipse, with manually set CLASSPATH and it works. I have to check what Eclipse is doing to my classpath... :-(
cringe