I have a web application. I want to instrument com.mycompany*jar inside XX.war/WEB-INF/lib. I have to do this with ant cobertura tasks.
Is it possible to instrument classes in selected jars inside war file with ant task?
If your jars contain classes that are all in the same package(s), you can use the form with "<includeClasses regex=..." (note: try regular glob patterns before you try regex, in my experience).
You can pass a war file, and it will instrument the classes from the pattern in any jar within WEB-INF/lib (or classes within WEB-INF/classes).
<cob:cobertura-instrument datafile="${todir}/${instrument.ser.filename}" >
<includeClasses regex="com.mycompany.*" />
<instrumentationClasspath>
<pathelement path="${war.file}"/>
</instrumentationClasspath>
</cob:cobertura-instrument>
Alternatively, if you really need to pinpoint specific jars within WEB-INF/lib/ folder, you can try the form with ant zip/jar filesets (I haven't tried it):
<cob:cobertura-instrument datafile="${todir}/${instrument.ser.filename}" >
<zipfileset src="${war.file}" includes="WEB-INF/lib/com.mycompany*.jar"/>
</cob:cobertura-instrument>
If all else fails, I would do what you probalby have considered: extract these jars, instrument them (with the first form) and re-package them.