| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <project name="org.apache.easyant.plugins#emma" |
| xmlns:ac="antlib:net.sf.antcontrib" |
| xmlns:ea="antlib:org.apache.easyant"> |
| |
| <ea:core-version requiredrevision="[0.9,+]" /> |
| |
| <ea:import mrid="org.apache.easyant.plugins#abstract-coverage;0.2" /> |
| <ea:import mrid="org.apache.easyant.plugins#abstract-test;0.2" /> |
| |
| <target name="emma:init" depends="abstract-coverage:init"> |
| <ea:parameter property="emma.metadata.path" description="location of emma metadata file" |
| default="${target.coverage.report}/coverage.em"/> |
| <ea:parameter property="emma.datafile.path" description="location of emma coverage data file" |
| default="${target.coverage.report}/coverage.ec"/> |
| |
| <ea:parameter property="emma.overrides.file" default="${target.coverage.report}/emma-overrides.properties"/> |
| |
| <!-- add datafile to system properties during test run, if it isn't explicitly set elsewhere --> |
| <property name="emma.properties" location="${emma.overrides.file}"/> |
| <mkdir dir="${target.coverage.report}" /> |
| |
| <!-- generate emma configuration file --> |
| <propertyfile file="${emma.overrides.file}"> |
| <entry key="metadata.out.file" value="${emma.metadata.path}"/> |
| <entry key="coverage.out.file" value="${emma.datafile.path}"/> |
| </propertyfile> |
| |
| <ac:if> |
| <not><contains string="${test.run.jvmargs}" substring="emma.properties"/></not> |
| <ac:then> |
| <ac:var name="test.run.jvmargs" value="-Demma.properties='${emma.properties}' ${test.run.jvmargs}"/> |
| </ac:then> |
| </ac:if> |
| |
| <available property="emma.available" classname="com.vladium.emma.emmaTask" classpathref="org.apache.easyant.plugins#emma.classpath"/> |
| <fail unless="emma.available" message="Emma is unavailable!" /> |
| <taskdef resource="emma_ant.properties" classpathref="org.apache.easyant.plugins#emma.classpath" /> |
| |
| </target> |
| |
| <target name="emma:instrument" depends="emma:init" if="has.src.test.java" extensionOf="abstract-test:test-ready"> |
| <ea:path overwrite="prepend" pathid="run.test.classpath"> |
| <pathelement path="${target.coverage.classes}" /> |
| <path refid="org.apache.easyant.plugins#emma.classpath"/> |
| </ea:path> |
| |
| <!-- Apply emma instrumentation to the classes in instrpath and copy to destdir --> |
| <emma verbosity="${coverage.verbosity}" properties="${emma.properties}"> |
| <instr instrpath="${target.main.classes}" destdir="${target.coverage.classes}" mode="copy" merge="true"> |
| <filter excludes="${coverage.exclude.filter}" /> |
| </instr> |
| </emma> |
| </target> |
| |
| <target name="emma:report" depends="emma:init,abstract-test:test-run" if="has.src.test.java" description="generate emma covera report"> |
| <!-- Generate code coverage report --> |
| <emma> |
| <report sourcepath="${src.main.java}"> |
| <fileset dir="${target.coverage.report}"> |
| <include name="*.em" /> |
| <include name="*.ec" /> |
| </fileset> |
| <!--TODO: Find an easy way to choose report type --> |
| <txt outfile="${target.coverage.report}/${coverage.report.name}.txt" /> |
| <xml outfile="${target.coverage.report}/${coverage.report.name}.xml" /> |
| <html outfile="${target.coverage.report}/${coverage.report.name}.html" /> |
| </report> |
| </emma> |
| </target> |
| |
| </project> |