标签:
build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <project name="edu_2.0" basedir="." default="war"> <!--引入配置信息--> <property file="build.properties" /> <!-- java源代码目录 --> <property name="src.dir" location="${basedir}/src" /> <!-- 构建目录 --> <property name="build.dir" location="${basedir}/build" /> <!-- class文件目录 --> <property name="build.classes" location="${build.dir}/classes" /> <!-- 打包目录 --> <property name="build.war" location="${build.dir}/war" /> <!-- web 应用的名字,也是打包后war的名字 --> <property name="web.name" value="edu_2.0" /> <!-- web 根目录 --> <property name="web.root" value="WebRoot" /> <property name="web.WEB-INF" location="${web.root}/WEB-INF" /> <property name="web.lib" location="${web.WEB-INF}/lib" /> <!-- 定义编译时的classpath --> <path id="compile.path"> <!--拷贝第三方jar包--> <fileset dir="${web.lib}" includes="*.lib"> <include name="*.jar" /> </fileset> <!--拷贝tomcat下的jar包--> <fileset dir="${tomcat_home}/lib"> <include name="**/*.jar" /> </fileset> </path> <!--创建目录--> <target name="init" description="初始化" depends="clean"> <!--mkdir创建目录--> <mkdir dir="${build.dir}" /> <mkdir dir="${build.classes}" /> <mkdir dir="${build.war}" /> <echo>初始化工作结束!</echo> </target> <!--web项目编译--> <target name="compile" depends="init" description="编译"> <javac destdir="${build.classes}" srcdir="src" includeantruntime="false" fork="true" bootclasspath="${java_home}/jre/lib/rt.jar" encoding="UTF-8"> <compilerarg line="-encoding UTF-8 "/> <classpath refid="compile.path"/> </javac> <!--拷贝源码中的配置文件--> <copy todir="${build.classes}"> <fileset dir="${src.dir}"> <exclude name="**/*.java" /> </fileset> </copy> <echo message="编译完成!"/> </target> <!--web项目打成war包--> <target name="war" depends="compile" description="打包war文件"> <war destfile="${build.war}/${web.name}.war"> <fileset dir="${web.root}" includes="**/*.*" /> <lib dir="${web.lib}" /> <webinf dir="${web.WEB-INF}" /> <classes dir="${build.classes}" /> </war> <echo>打包完成!</echo> </target> <!--创建目录--> <target name="clean" description="清理"> <delete dir="${build.classes}" /> <delete dir="${build.war}" /> <echo>清理完成!</echo> </target> </project>
build.properties
tomcat_home = D:\\ProgramFiles\\apache-tomcat-7.0.65 java_home = D:\\ProgramFiles\\jdk1.7.0_25
项目结构
标签:
原文地址:http://www.cnblogs.com/lbblog/p/5443220.html