So I have a java project in Eclipse. I build the war file via ant. Which I can invoke from Eclipse, or from the command line or via Jenkins. I am setting up the environment is such a way as to try and keep all three of those ways of building working, and with as little changing of the environment as possible to make it happen.
So I am currently doing the compile, creating the war, generating javadoc, and running junits via my ant build.xml
Trying to add Cobertura code coverage to the mix.
I have installed the Jenkins for Cobertura and I’m now trying to get the junit running to work with Cobertura to properly instrument the classes and generate the coverage file.
The cobertura doc says to start by defining the task as follows.
<property name="cobertura.dir" value="C:/javastuff/cobertura" />
<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" />
Don’t like that C:\ obviously … I need a valid cobertura.dir … but it is not really obvious how to configure it. Jenkins puts all the classes for the plugin here
.jenkins/plugins/cobertura
And the file structure underneath this is as follows.
drwxrwxr-x 2 vpbuild vpbuild 4096 Jan 4 10:42 images
drwxrwxr-x 3 vpbuild vpbuild 4096 Dec 15 12:36 META-INF
-rw-rw-r– 1 vpbuild vpbuild 0 Jan 4 10:41 .timestamp
drwxrwxr-x 4 vpbuild vpbuild 4096 Dec 15 12:36 WEB-INF
So if this was to be my cobertura.dir there is no lib subdirectory defined here. There is in WEB-INF, but there is no cobertura jar there … so none of it seems quite right.
I have also downloaded the cobertura jar separately, and put that in ANT_HOME/lib, to hopefully assist with making the cobertura tasks more visible to ANT, but not sure how that would affect what I need to do as far as the build.xml.
Anyone have any experience with configuring cobertura so that it can run via ant both within and outside jenkins in this way ? What does the build.xml need to look like to make it happen ?
-Jim
The Jenkins Cobertura plugin merely processes and displays your code coverage results; it doesn’t include the Cobertura tool itself.
You should download the latest Cobertura binaries and unpack them into your C:\javastuff\cobertura directory. You’ll then have cobertura.jar plus a lib subdirectory containing the other required dependencies that go into cobertura.classpath.