ANT xmlproperty: multiple value demux properties
I am using cobertura to calculate my test coverage. I want my ant script to display information about specific packages.
So far I have had:
<target name="coverage-check">
<loadfile property="coveragexml" srcFile="${coverage.report.dir}/coverage.xml">
<filterchain>
<linecontains negate="true">
<contains value="!DOCTYPE"/>
</linecontains>
</filterchain>
</loadfile>
<xmlproperty validate="false">
<string value="${coveragexml}"/>
</xmlproperty>
</target>
It works to download information about koberrure in ant variables, such as: coverage.packages.package(name)=lots,of,package,names
.
I would like to find a way to assign a specific package name (from one variable) to coverage metrics stored in other variables. If I was using python, lisp, or the like, I would zip them together and then search. I don't know how to do zipping or searching in ant.
source to share
I made an example using xmltask
<target name="xml-test">
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpathref="extension.classpath"/>
<property name="xml.file" location="coverage.xml"></property>
<!-- package to search for -->
<property name="packageName" value="foo"></property>
<!-- extract for example line-rate and echo it -->
<xmltask source="${xml.file}">
<copy path="/coverage/packages/package[@name='${packageName}']/@line-rate" property="line-rate" />
</xmltask>
<echo>
Line Rate: ${line-rate}
</echo>
<!-- extract complete xml-block for package ${packageName}
and write it to other file
-->
<xmltask source="${xml.file}">
<copy path="/coverage/packages/package[@name='${packageName}']" buffer="foo-buffer" append="true" />
</xmltask>
<!-- write cut out to file -->
<xmltask dest="foo-coverage.xml">
<insert path="/" buffer="foo-buffer"/>
</xmltask>
</target>
The xml taken from the original file, unfortunately, cannot be echoed by default, but written to a different file.
This is not a solution, but an example that might help.
I think it would be less work to create a custom ant task.
source to share