Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Ant Example code for Emma Instrumentation and reports

rajeshkumar created the topic: Ant Example code for Emma Instrumentation and reports

In-place instrument a certain subset of already compiled classes using overwrite mode and several coverage filters:

<emma enabled="${emma.enabled}" >
      <instr instrpathref="${out.dir}/classes"
             mode="overwrite"
      >
        <!-- always exclude every class with a "Test" in the name: -->
        <filter excludes="*Test*" />
        <!-- don't instrument everything in "${out.dir}/classes",
             only the stuff I am working on now: -->
        <filter file="myincludes.txt" />
        <!-- additional ANT command line hook: -->
        <filter value="${emma.filter}" />
      </instr>
    </emma>

Don’t overwrite compiled classes that later need to go into official release jars (stay in copy mode). However, use incremental instrumentation for fast personal testing:

<emma enabled="${emma.enabled}" >
          <instr instrpathref="${out.dir}/classes"
                 outdir="${out.dir}/classes-instrumented"
                 merge="yes"
                 filter="${emma.filter}"
          />
    </emma>
 

Take all jars already produced by the product build and make test (coverage-enabled) copies of them:

    <emma enabled="${emma.enabled}" >
          <instr mode="fullcopy"
                 outdir="${out.instr.dir}"
                 merge="no"
                 filter="${emma.filter}"
          >
            <instrpath>
              <fileset dir="${out.dir}" includes="**/*.jar" />
            </instrpath>
          </instr>
    </emma>
 <copy todir="${dist}">
      <fileset dir="${src}"
               includes="**/images/*"
               excludes="**/*.gif"
      />
    </copy>
<copy todir="${dist}">
      <fileset dir="${src}">
        <include name="**/images/*"/>
        <exclude name="**/*.gif"/>
      </fileset>
    </copy>
 

Groups all files in directory ${server.src} that are Java source files and don’t have the text Test in their name.

<fileset dir="${server.src}" casesensitive="yes">
      <include name="**/*.java"/>
      <exclude name="**/*Test*"/>
</fileset>

Groups the same files as the above example, but also establishes a PatternSet that can be referenced in other elements, rooted at a different directory.

<fileset dir="${server.src}" casesensitive="yes">
      <patternset id="non.test.sources">
        <include name="**/*.java"/>
        <exclude name="**/*Test*"/>
      </patternset>
</fileset>
 

Groups all files in directory ${client.src}, using the same patterns as the above example.

<fileset dir="${client.src}" >
  	<patternset refid="non.test.sources"/>
</fileset>

Groups the same files as the top example, but using the selector.

<fileset dir="${server.src}" casesensitive="yes">
  <filename name="**/*.java"/>
  <filename name="**/*Test*" negate="true"/>
</fileset>

Groups the same files as the previous example using a combination of the selector and the selector container.

<fileset dir="${server.src}" casesensitive="yes">
  <filename name="**/*.java"/>
  <not>
    <filename name="**/*Test*"/>
  </not>
</fileset>

Selects all files in src/main

<fileset dir="src" includes="main/" />
 
     	<emma enabled="${emma.enabled}" >
          <instr mode="overwrite" 
          	 instrpath="${jar.location}"
                 destdir="${inst.jar.location}"	
                 metadatafile="${inst.jar.location}/metadata.emma"
                 merge="no" >
            	<instrpath>
              		<fileset dir="${jar.location}" includes="elance-services.jar,web-classes.jar,applet.jar,application-ejb.jar" />
            	</instrpath>
 
         </instr>
      	</emma>
 
 
      	<emma enabled="${emma.enabled}" >
	          <instr mode="fullcopy" 
	          	 instrpath="${jar.location}"
	          	 outdir="${inst.jar.location}"
 
	                 metadatafile="${inst.jar.location}/metadata.emma"
	                 merge="no" >
	            	<instrpath>
	              		<fileset dir="${jar.location}" includes="elance-services.jar,web-classes.jar,applet.jar,application-ejb.jar" />
	            	</instrpath>
 
	         </instr>
      	</emma>
 

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x