您的位置:首页 > 产品设计 > UI/UE

Simple Ant build.xml file

2013-04-21 10:18 357 查看
<?xml version="1.0" encoding="UTF-8"?>
<project name="junitDemo02" default="test" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="src.dir" location="src"/>
<property name="src.java.dir" location="${src.dir}/java"/>
<property name="src.test.dir" location="${src.dir}/test"/>
<property name="build.dir" location="build"/>
<property name="classes.java.dir" location="${build.dir}/classes/java"/>
<property name="classes.test.dir" location="${build.dir}/classes/test"/>
<property name="lib.dir" location="lib"/>
<property name="test.report.dir" location="${build.dir}/report"/>

<path id="classpath.java.compile">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>

<!-- classpath for compiling test source files-->
<path id="classpath.test.compile">
<path refid="classpath.java.compile"/>
<pathelement location="${classes.java.dir}"/>
</path>

<!-- classpath for running tests -->
<path id="classpath.test.run">
<path refid="classpath.test.compile"/>
<pathelement location="${classes.test.dir}"/>
</path>

<target name="init" description="-->  Init the directories">
<mkdir dir="${src.dir}"/>
<mkdir dir="${src.java.dir}"/>
<mkdir dir="${src.test.dir}"/>
<mkdir dir="${lib.dir}"/>
</target>

<target name="resolve" description="-->  resolve all the dependencies by ivy" depends="init">
<ivy:retrieve/>
</target>

<target name="clean" description="-->  clean the build directory">
<delete dir="${build.dir}"/>
</target>

<target name="compile.java" description="-->  compile all the main java files">
<mkdir dir="${classes.java.dir}"/>
<javac destdir="${classes.java.dir}" srcdir="${src.java.dir}" includeAntRuntime="yes"/>
</target>

<target name="compile.test" description="-->  compile all the tests source files">
<mkdir dir="${classes.test.dir}"/>
<javac destdir="${classes.test.dir}" srcdir="${src.test.dir}" classpathref="classpath.test.compile" includeAntRuntime="yes"/>
</target>

<target name="compile" description="-->  compile both main and test source files" depends="clean, compile.java, compile.test"/>

<target name="test" depends="compile">
<mkdir dir="${test.report.dir}"/>
<junit printsummary="yes" fork="yes">
<formatter type="xml"/>
<batchtest todir="${test.report.dir}">
<fileset dir="${src.test.dir}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
<classpath refid="classpath.test.run"/>
</junit>
</target>

<target name="report" depends="test" description="-->  create the test result report">
<mkdir dir="${test.report.dir}/html"/>
<junitreport todir="${test.report.dir}">
<fileset dir="${test.report.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${test.report.dir}/html"/>
</junitreport>
</target>
</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: