Posted on 2007-12-12 12:23
G_G 阅读(502)
评论(0) 编辑 收藏 所属分类:
ant
原代码:http://www.blogjava.net/Files/Good-Game/myAnt.rar
对一般开发 使用的ant
<?xml version="1.0"?>
<project name="general" default="doc">
<!-- 使用说明:
需要设置的参数 : src.dir 、 classes.dir
-->
<!-- properies -->
<property name="src.dir" value="src" />
<property name="lib.dir" value="lib" />
<property name="report.dir" value="report" />
<property name="classes.dir" value="bin" />
<property name="dist.dir" value="dist" />
<property name="doc.dir" value="doc"/>
<!-- 定义classpath -->
<path id="master-classpath">
<fileset file="${lib.dir}/*.jar" />
<pathelement path="${classes.dir}"/>
</path>
<!-- 初始化任务 -->
<target name="init">
<copy todir ="${classes.dir}">
<fileset dir ="${src.dir}">
<exclude name="**/build.xml"/>
<exclude name="**/*.java" />
</fileset >
</copy >
</target>
<!-- 编译 -->
<target name="compile" depends="init" description="compile the source files">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" target="1.4">
<classpath refid="master-classpath"/>
</javac>
</target>
<!-- 测试 -->
<target name="test" depends="compile" description="run junit test">
<mkdir dir="${report.dir}"/>
<junit printsummary="on"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath" />
<formatter type="plain"/>
<batchtest todir="${report.dir}">
<fileset dir="${classes.dir}">
<include name="**/Test*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
***********************************************************
**** One or more tests failed! Check the output ****
***********************************************************
</fail>
</target>
<!-- 打包成jar -->
<target name="pack" depends="test" description="make .jar file">
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/hello.jar" basedir="${classes.dir}">
<exclude name="**/*Test.*" />
<exclude name="**/Test*.*" />
</jar>
</target>
<!-- 输出api文档 -->
<target name="doc" depends="pack" description="create api doc">
<mkdir dir="${doc.dir}" />
<javadoc
destdir="${doc.dir}"
author="true"
version="true"
use="true"
windowtitle="Test API">
<fileset dir="src" defaultexcludes="yes">
<include name="**/**.java"/>
<exclude name="**/*Test.java" />
<exclude name="**/Test*.*" />
</fileset>
</javadoc>
</target>
<!-- clean doc -->
<target name="clean_doc" description="create api doc">
<delete includeEmptyDirs = "true">
<fileset dir="${doc.dir}"/>
</delete >
</target>
<!-- clean class and lib -->
<target name="clean_class_dist" description="create class dist">
<delete>
<fileset dir="${classes.dir}"/>
<fileset dir="${dist.dir}"/>
</delete >
</target>
</project> ant XDoclet Generation
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant XDoclet Generation" default="_xdoclet_generation_">
<property file="xdoclet-build.properties"/>
<!-- 使用说明:
需要设置的参数 : java.home 、 xdoclet.home
-->
<property environment="env"/>
<property name="java.home" value="${env.JAVA_HOME}"/>
<property name="xdoclet.home"
value="D:\hbn\hibernate-3.2\xdoclet-1.2.3"/>
<path id="xdoclet.classpath">
<pathelement location="${java.home}/**/*.jar"/>
<fileset dir="${xdoclet.home}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="_xdoclet_generation_" depends="N10004"/>
<target name="N10004" description="Standard Hibernate">
<taskdef classpathref="xdoclet.classpath"
classname="xdoclet.modules.hibernate.HibernateDocletTask"
name="hibernatedoclet"/>
<hibernatedoclet excludedTags="@version,@author,@todo,@see"
destDir="src"
addedTags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version}" >
<fileset dir="src" includes="**/*.java" >
</fileset>
<hibernate>
</hibernate>
</hibernatedoclet>
</target>
</project>