添加系统变量 path=ant目录/bin
cmd中 输入ant
出现
Buildfile: build.xml does not exist!
Build failed
ant 配置成功
当前目录建立build.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="war" default="run" basedir=".">
<property name="src" value="${basedir}/src">
</property>
<property name="item" value="${basedir}/StrutsPro">
</property>
<property name="web" value="${basedir}/WebRoot">
</property>
<property name="app" value="G:/ACD/tomcat5.0">
</property>
<property name="war" value="StrutsPro.war">
</property>
<path id="compile.path">
<fileset dir="${app}/common/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<mkdir dir="${item}"/>
<mkdir dir="${item}/WEB-INF"/>
<mkdir dir="${item}/WEB-INF/classes"/>
<mkdir dir="${item}/WEB-INF/lib"/>
</target>
<target name="javac" depends="init">
<javac srcdir="src" destdir="${item}/WEB-INF/classes">
<classpath refid="compile.path"></classpath>
</javac>
<move todir="${item}/WEB-INF/classes">
<fileset dir="${src}" includes="*/*.*" excludes="*/*.java"></fileset>
</move>
<move todir="${item}/WEB-INF/lib">
<fileset dir="${web}/WEB-INF/lib" includes="*.jar"></fileset>
</move>
<move todir="${item}">
<fileset dir="${web}" includes="*.*"></fileset>
</move>
</target>
<target name="towar">
<jar jarfile="${war}" basedir="${item}"></jar>
</target>
<target name="toapp">
<copy todir="${app}/webapps">
<fileset dir="${basedir}">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="run">
<ant target="init"/>
<ant target="javac"/>
<ant target="towar"/>
<ant target="toapp"/>
</target>
</project>
键入上面的命令 同时ant 就会首先执行 project defalut属性指定的target
其他命令api上查询1