<?xml version="1.0" encoding="UTF-8"?>
<project name="TestActivityPlatform" default="all" basedir=".">
<!--设置Java类被注入字节码后存放的路径-->
<property name="bin.instrument.dir" location="${basedir}/instrbin" />
<!--设置覆盖率元数据和报告的路径-->
<property name="coverage.dir" location="${basedir}/coverage" />
<!--设置junit报告的路径 -->
<property name="junitReport.html.dir" location="${basedir}/junitReport/html" />
<property name="junitReport.xml.dir" location="${basedir}/junitReport/xml" />
<!-- 日志 目录-->
<property name="logs.dir" location="${basedir}/logs" />
<!--设置主代码编译文件存放路径-->
<property name="realesBin.dir" location="${basedir}/realesBin" />
<!--设置主代码编译文件存放路径-->
<property name="war.dir" location="${basedir}/war" />
<!--设置测试代码编译文件路径-->
<property name="testBin.dir" location="${basedir}/testBin" />
<!--设置主题代码源路径-->
<property name="src.main.dir" location="${basedir}/src" />
<!--设置测试代码源路径-->
<property name="src.test.dir" location="${basedir}/src" />
<!--设置引用包的位置-->
<property name ="libs" value ="${basedir}/webapp/WEB-INF/lib"/>
<!--指示需要注入字节码的Java类的路径-->
<path id="classpath.main">
<pathelement location="${realesBin.dir}" />
</path>
<!--指示 emma.jar 和emma_ant.jar 的路径-->
<path id="emma.lib">
<pathelement location="${libs}/emma.jar" />
<pathelement location="${libs}/emma_ant.jar" />
</path>
<path id="libPath">
<fileset dir="${libs}">
<include name="*.jar"/>
</fileset>
</path>
<!--允许emma-->
<property name="emma.enabled" value="true" />
<!--为ANT添加EMMA任务-->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<target name="init">
<delete dir="${bin.instrument.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${junitReport.html.dir}"/>
<delete dir="${junitReport.xml.dir}"/>
<delete dir="${realesBin.dir}"/>
<delete dir="${testBin.dir}"/>
<delete dir="${war.dir}"/>
<delete dir="${logs.dir}"/>
<mkdir dir="${logs.dir}" />
</target>
<target name="compile-src.main">
<mkdir dir="${realesBin.dir}" />
<javac srcdir="${src.main.dir}" destdir="${realesBin.dir}" includeantruntime="on" compiler="javac1.6" source="1.6" encoding="UTF-8" debug="on">
<classpath location="${realesBin.dir}"/>
<classpath refid="libPath"/>
</javac>
<copydir dest="${realesBin.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${realesBin.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--对编译在路径bin.main.dir中的Java类注入字节码, 并且把注入字节码的新Java类存放到路径bin.instrument.dir-->
<!--覆盖率的元数据存放在路径coverage.dir中-->
<target name="instrument">
<mkdir dir="${bin.instrument.dir}" />
<mkdir dir="${coverage.dir}" />
<emma enabled="${emma.enabled}">
<instr instrpathref="classpath.main" destdir="${bin.instrument.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true">
</instr>
</emma>
<copy todir="${bin.instrument.dir}">
<fileset dir="${realesBin.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<copydir dest="${bin.instrument.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${bin.instrument.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--执行测试用例同时生成junit测试报告和emma代码覆盖率报告-->
<target name="test">
<mkdir dir="${junitReport.html.dir}" />
<mkdir dir="${junitReport.xml.dir}" />
<junit fork="true" forkmode="once" printsummary="yes" errorproperty="test.error" showoutput="on">
<!--指明代码覆盖率的元数据的存放位置-->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/metadata.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<classpath location="${bin.instrument.dir}"/>
<classpath refid="libPath"/>
<classpath refid="emma.lib" />
<formatter type="xml" />
<!--执行所ProjectAllTest.class的junit测试用例-->
<batchtest todir="${junitReport.xml.dir}" haltonfailure="no">
<fileset dir="${bin.instrument.dir}">
<include name="**/ProjectAllTest.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="gen-report-junit">
<!--生成junit测试报告-->
<junitreport todir="${junitReport.html.dir}">
<fileset dir="${junitReport.xml.dir}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${junitReport.html.dir}" />
</junitreport>
</target>
<!--生成代码覆盖率报告-->
<target name="gen-report-coverage">
<!--如果属性emma.enabled的值是true,就生成代码覆盖率报告 -->
<emma enabled="${emma.enabled}">
<report sourcepath="${src.main.dir}"
sort="+block,+name,+method,+class"
metrics="method:70,block:80,line:80,class:100">
<fileset dir="${coverage.dir}">
<include name="*.emma" />
</fileset>
<html outfile="${coverage.dir}/coverage.html"
depth="method" columns="name,class,method,block,line" encoding="utf-8"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
</report>
</emma>
</target>
<target name ="war" depends="compile-src.main">
<mkdir dir="${war.dir}"/>
<war destfile ="${war.dir}/TMS.war" webxml ="${basedir}/webapp/WEB-INF/web.xml">
<lib dir ="${libs}">
<exclude name="jsp-api.jar"/>
<exclude name="servlet-api.jar"/>
</lib>
<classes dir ="${realesBin.dir}">
<exclude name="cn/tv189/activityplatform/test/"/>
</classes>
<fileset dir ="${basedir}/webapp">
<include name="pages/*.*"/>
<include name="css/*.*"/>
</fileset>
</war>
</target>
<target name="all" depends="init,compile-src.main,instrument,test,gen-report-coverage,gen-report-junit,war">
</target>
</project>
<project name="TestActivityPlatform" default="all" basedir=".">
<!--设置Java类被注入字节码后存放的路径-->
<property name="bin.instrument.dir" location="${basedir}/instrbin" />
<!--设置覆盖率元数据和报告的路径-->
<property name="coverage.dir" location="${basedir}/coverage" />
<!--设置junit报告的路径 -->
<property name="junitReport.html.dir" location="${basedir}/junitReport/html" />
<property name="junitReport.xml.dir" location="${basedir}/junitReport/xml" />
<!-- 日志 目录-->
<property name="logs.dir" location="${basedir}/logs" />
<!--设置主代码编译文件存放路径-->
<property name="realesBin.dir" location="${basedir}/realesBin" />
<!--设置主代码编译文件存放路径-->
<property name="war.dir" location="${basedir}/war" />
<!--设置测试代码编译文件路径-->
<property name="testBin.dir" location="${basedir}/testBin" />
<!--设置主题代码源路径-->
<property name="src.main.dir" location="${basedir}/src" />
<!--设置测试代码源路径-->
<property name="src.test.dir" location="${basedir}/src" />
<!--设置引用包的位置-->
<property name ="libs" value ="${basedir}/webapp/WEB-INF/lib"/>
<!--指示需要注入字节码的Java类的路径-->
<path id="classpath.main">
<pathelement location="${realesBin.dir}" />
</path>
<!--指示 emma.jar 和emma_ant.jar 的路径-->
<path id="emma.lib">
<pathelement location="${libs}/emma.jar" />
<pathelement location="${libs}/emma_ant.jar" />
</path>
<path id="libPath">
<fileset dir="${libs}">
<include name="*.jar"/>
</fileset>
</path>
<!--允许emma-->
<property name="emma.enabled" value="true" />
<!--为ANT添加EMMA任务-->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<target name="init">
<delete dir="${bin.instrument.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${junitReport.html.dir}"/>
<delete dir="${junitReport.xml.dir}"/>
<delete dir="${realesBin.dir}"/>
<delete dir="${testBin.dir}"/>
<delete dir="${war.dir}"/>
<delete dir="${logs.dir}"/>
<mkdir dir="${logs.dir}" />
</target>
<target name="compile-src.main">
<mkdir dir="${realesBin.dir}" />
<javac srcdir="${src.main.dir}" destdir="${realesBin.dir}" includeantruntime="on" compiler="javac1.6" source="1.6" encoding="UTF-8" debug="on">
<classpath location="${realesBin.dir}"/>
<classpath refid="libPath"/>
</javac>
<copydir dest="${realesBin.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${realesBin.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--对编译在路径bin.main.dir中的Java类注入字节码, 并且把注入字节码的新Java类存放到路径bin.instrument.dir-->
<!--覆盖率的元数据存放在路径coverage.dir中-->
<target name="instrument">
<mkdir dir="${bin.instrument.dir}" />
<mkdir dir="${coverage.dir}" />
<emma enabled="${emma.enabled}">
<instr instrpathref="classpath.main" destdir="${bin.instrument.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true">
</instr>
</emma>
<copy todir="${bin.instrument.dir}">
<fileset dir="${realesBin.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<copydir dest="${bin.instrument.dir}/config" src="${src.main.dir}/config">
</copydir>
<copy todir="${bin.instrument.dir}" overwrite="true">
<fileset dir="${src.main.dir}">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!--执行测试用例同时生成junit测试报告和emma代码覆盖率报告-->
<target name="test">
<mkdir dir="${junitReport.html.dir}" />
<mkdir dir="${junitReport.xml.dir}" />
<junit fork="true" forkmode="once" printsummary="yes" errorproperty="test.error" showoutput="on">
<!--指明代码覆盖率的元数据的存放位置-->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/metadata.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<classpath location="${bin.instrument.dir}"/>
<classpath refid="libPath"/>
<classpath refid="emma.lib" />
<formatter type="xml" />
<!--执行所ProjectAllTest.class的junit测试用例-->
<batchtest todir="${junitReport.xml.dir}" haltonfailure="no">
<fileset dir="${bin.instrument.dir}">
<include name="**/ProjectAllTest.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="gen-report-junit">
<!--生成junit测试报告-->
<junitreport todir="${junitReport.html.dir}">
<fileset dir="${junitReport.xml.dir}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${junitReport.html.dir}" />
</junitreport>
</target>
<!--生成代码覆盖率报告-->
<target name="gen-report-coverage">
<!--如果属性emma.enabled的值是true,就生成代码覆盖率报告 -->
<emma enabled="${emma.enabled}">
<report sourcepath="${src.main.dir}"
sort="+block,+name,+method,+class"
metrics="method:70,block:80,line:80,class:100">
<fileset dir="${coverage.dir}">
<include name="*.emma" />
</fileset>
<html outfile="${coverage.dir}/coverage.html"
depth="method" columns="name,class,method,block,line" encoding="utf-8"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
</report>
</emma>
</target>
<target name ="war" depends="compile-src.main">
<mkdir dir="${war.dir}"/>
<war destfile ="${war.dir}/TMS.war" webxml ="${basedir}/webapp/WEB-INF/web.xml">
<lib dir ="${libs}">
<exclude name="jsp-api.jar"/>
<exclude name="servlet-api.jar"/>
</lib>
<classes dir ="${realesBin.dir}">
<exclude name="cn/tv189/activityplatform/test/"/>
</classes>
<fileset dir ="${basedir}/webapp">
<include name="pages/*.*"/>
<include name="css/*.*"/>
</fileset>
</war>
</target>
<target name="all" depends="init,compile-src.main,instrument,test,gen-report-coverage,gen-report-junit,war">
</target>
</project>