关于MyEclipse 自动生成 Ant Build.xml 配置文件,生成的方法很隐蔽,是自己无意中找到的.
选择你要生成Build.xml文件的项目,右键. Export-> General -> Ant Buildfiles .
点Next,再点Finish.
OK,生成完毕.然后自己再根据需求去修改.
然后添加节点,生成war
- <target name="war" depends="build-project">
- <mkdir dir="build/classes"/>
- <mkdir dir="dist"/>
- <war destfile="dist/xd.war" webxml="WebRoot/WEB-INF/web.xml">
- <fileset dir="WebRoot"/>
- <lib dir="WebRoot/WEB-INF/lib"/>
- <classes dir="build/classes"/>
- </war>
- </target>
附上构建脚本:
- <?xml version="1.0" ?>
- <project name="AntExample1" default="war">
- <path id="compile.classpath">
- <fileset dir="WebContent/WEB-INF/lib">
- <include name="*.jar"/>
- </fileset>
- </path>
- <target name="init">
- <mkdir dir="build/classes"/>
- <mkdir dir="dist" />
- </target>
- <target name="compile" depends="init" >
- <javac destdir="build/classes" debug="true" srcdir="src">
- <classpath refid="compile.classpath"/>
- </javac>
- </target>
- <target name="war" depends="compile">
- <war destfile="dist/AntExample.war" webxml="WebContent/WEB-INF/web.xml">
- <fileset dir="WebContent"/>
- <lib dir="WebContent/WEB-INF/lib"/>
- <classes dir="build/classes"/>
- </war>
- </target>
- <target name="clean">
- <delete dir="dist" />
- <delete dir="build" />
- </target>
- </project>