Ant实用脚本

<project name="product.highlevel" default="dist" basedir=".">

    <description>simple example</description>

    <property name="destJar" value="highlevel.jar" />

    <property name="jar1" value="lowlevel.jar" />

    <property name="jar2" value="framework.jar" />

    <property name="jar3" value="business.jar" />

    <property name="src" location="src" />

    <property name="build" location="build" />

    <property name="dist" location="dist" />

    <property name="FullLib" value="c:\\Lib" />

    <property name="DestJarFile" value="${FullLib}/${destJar}" />

    <path id="compile.classpath">

        <fileset dir="lib">

        <include name="*.jar"/>

        </fileset>

    </path>

    <target name="init">

    <tstamp />

    <mkdir dir="${build}"/>

    <mkdir dir="${dest}"/>

    <mkdir dir="./lib"/>

    </target>

   

    <target name="compile" depends="init,CopyFrom" description="compile the source">

    <javac srcdir="${src}" destdir="${build}" classpathref="compile.classpath" source="1.5" debug="true" />

    </target>

    <target name="dist" depends="compile">

        <jar jarfile="${DestJarFile}" basedir="${build}" />

    </target>

    <target name="clean" >

        <delete dir="${build}" />

        <delete dir="${dest}" />

        <delete dir="./lib" />

    </target> 

    <target name="CopyFrom" >

        <copy todir="./lib" file="${FullLib}/${jar1}" />

        <copy todir="./lib" file="${FullLib}/${jar2}" />

        <copy todir="./lib" file="${FullLib}/${jar3}" />

   </target> 

 </project>

原文地址:https://www.cnblogs.com/huqingyu/p/1375444.html