From: John W. L. <Joh...@sa...> - 2011-05-17 19:58:10
|
I would take cobertura.jar out of the ext directory. The bits you have shown look right except for the cobertura-instrument call. If you want to use emma.classpath, you will need to use this: <includeClasses regex="my.package.*" /> <instrumentationClasspath> <path refid="emma.classpath" /> </instrumentationClasspath> Please verify the cobertura.jar and the lib directory are under the cobertura-1.9.4.1 directory that is under your basedir. I can't see how you are defining your basedir. Try using a full path: <property name="cobertura.dir" value="/full/path/to/cobertura-1.9.4.1"/> John From: Soula, William [mailto:ws...@po...] Sent: Tuesday, May 17, 2011 3:19 PM To: 'cob...@li...' Subject: [Cobertura-devel] Create cobertura tasks in ant I have started using cobertura and everything was going fine till I got to the section about creating the ant tasks. Below is my code to try and create the task: <property name="cobertura.out.instr" value="${basedir}/outinstr"/> <mkdir dir="${cobertura.out.instr}"/> <property name="coverage.dir" value="${basedir}/coverage"/> <property name="cobertura.dir" value="${basedir}/cobertura-1.9.4.1"/> <echo message="${cobertura.dir}/cobertura.jar"/> <path id="cobertura.lib"> <fileset dir="${cobertura.dir}"> <include name="cobertura.jar"/> <include name="lib/**/*.jar"/> </fileset> </path> <taskdef resource="tasks.properties" classpathref="cobertura.lib"/> Then I create/delete some directories, setup the path to my classes and call cobertura-instrument like below: <cobertura-instrument todir="${cobertura.out.instr}"> <path refid="emma.classpath"/> </cobertura-instrument> And then ant fails with: build.xml:305: Problem: failed to create task or type cobertura-instrument Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any <presetdef>/<macrodef> declarations have taken place. I have used emma in the past and got that setup recently and I had to add the emma.jar to my java install in java-1.6.0_20/jre/lib/ext so I thought cobertura might be the same so I put the cobertura.jar in that folder. This got me further but now the error is: build.xml:290: taskdef A class needed by class net.sourceforge.cobertura.ant.InstrumentTask cannot be found: org/apache/tools/ant/taskdefs/MatchingTask I am currently using ant 1.7.1, if I use ant 1.8.2 then it tells you what jars were in the class load path and it just listed the cobertura jars, but the class it is complaining about is in ant.jar. So I tried adding all of ant's lib folder to cobertura and that didn't work. I tried putting ant.jar into java/jre/lib/ext but that caused even more problems. Every example I have been able to find online says to put cobertura.jar and its corresponding jars in the lib folder into a pathref and then hand that off to cobertura when creating the ant tasks and everything works, but that is not what I am experiencing. Does anyone have any idea what I am doing wrong? Thanks, Will |