按网上的操作,实现一下。
build.xml:
<?xml version="1.0" ?> <project name ="antwebproject" default ="war" basedir ="."> <property name ="classes" value ="build/classes"/> <property name ="build" value ="build"/> <property name ="lib" value ="WebRoot/WEB-INF/lib"/> <!-- 删除build 路径--> <target name ="clean"> <delete dir ="build"/> </target> <!-- 建立build/classes 路径,并编译class 文件到build/classes 路径下--> <target name ="compile" depends ="clean"> <mkdir dir ="${classes}"/> <javac srcdir ="src" destdir ="${classes}"/> </target> <!-- 打war 包--> <target name ="war" depends ="compile"> <war destfile ="${build}/antwebproject.war" webxml ="WebRoot/WEB-INF/web.xml"> <!-- 拷贝WebRoot 下除了WEB-INF 和META-INF 的两个文件夹--> <fileset dir ="WebRoot" includes ="**/*.jsp"/> <!-- 拷贝lib 目录下的jar 包--> <lib dir ="${lib}"/> <!-- 拷贝build/classes 下的class 文件--> <classes dir ="${classes}"/> </war> </target> </project>
定义的目录结构:
时间: 2024-11-30 06:49:34