引用:http://www.cnitblog.com/reene/archive/2011/06/30/74504.html1. emma taskdef <!-- Emma configuration -->
<
property
name
="emma.dir"
value
="${android.sdk.root}/tools/lib"
/>
< path id ="emma.lib.dir" >
< pathelement location ="${emma.dir}/emma.jar" />
< pathelement location ="${emma.dir}/emma_ant.jar" />
</ path >
< taskdef resource ="emma_ant.properties" classpathref ="emma.lib.dir" />
<!-- End of emma configuration -->
< path id ="emma.lib.dir" >
< pathelement location ="${emma.dir}/emma.jar" />
< pathelement location ="${emma.dir}/emma_ant.jar" />
</ path >
< taskdef resource ="emma_ant.properties" classpathref ="emma.lib.dir" />
<!-- End of emma configuration -->
2. <!-- - - - - - - - - - - - - - - - - -
target: emma-instrument
- - - - - - - - - - - - - - - - - -->
< target name ="emma.instrument" if ="enable.emma.on.test" >
< property name ="emma.enabled" value ="true" />
< echo > Instrumenting classes from ${project.base.dir}/${android.project.dir}/bin,${project.base.dir}/${android.project.dir}/libs/sup-client.jar </ echo >
<!-- It only instruments class files, not any external libs -->
< emma enabled ="${emma.enabled}" >
< instr mode ="overwrite"
instrpath ="${project.base.dir}/${android.project.dir}/bin,${project.base.dir}/${android.project.dir}/libs/sup-client.jar"
outdir ="${project.base.dir}/${android.project.dir}/bin" >
</ instr >
<!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
user defined file -->
</ emma >
< echo > Copy emma. to project libs </ echo >
< copy todir ="${project.base.dir}/${android.project.dir}/libs" overwrite ="true" >
< fileset dir ="${emma.dir}" includes ="emma_device.jar" />
</ copy >
</ target >
- - - - - - - - - - - - - - - - - -->
< target name ="emma.instrument" if ="enable.emma.on.test" >
< property name ="emma.enabled" value ="true" />
< echo > Instrumenting classes from ${project.base.dir}/${android.project.dir}/bin,${project.base.dir}/${android.project.dir}/libs/sup-client.jar </ echo >
<!-- It only instruments class files, not any external libs -->
< emma enabled ="${emma.enabled}" >
< instr mode ="overwrite"
instrpath ="${project.base.dir}/${android.project.dir}/bin,${project.base.dir}/${android.project.dir}/libs/sup-client.jar"
outdir ="${project.base.dir}/${android.project.dir}/bin" >
</ instr >
<!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
user defined file -->
</ emma >
< echo > Copy emma. to project libs </ echo >
< copy todir ="${project.base.dir}/${android.project.dir}/libs" overwrite ="true" >
< fileset dir ="${emma.dir}" includes ="emma_device.jar" />
</ copy >
</ target >
333