首页 > 代码库 > Ant自动构建

Ant自动构建

Ant+jenkins+tomcat

<project name="buildWar" default="clean">      <property name="tomcat.home" value="http://www.mamicode.com/opt/tomcat" />    <property name="build.path" value="http://www.mamicode.com/build/classes" />    <property name="output.path" value="http://www.mamicode.com/output" />    <!-- 配置编译需要的jar包 -->    <path id="compile.classpath">          <fileset dir="WebRoot/WEB-INF/lib">              <include name="*.jar"/>          </fileset>          <fileset dir="${tomcat.home}/lib">              <include name="**/*.jar"/>          </fileset>      </path>       <!-- 初始化,新建文件夹 -->    <target name="init">          <mkdir dir="${build.path}"/>          <mkdir dir="${output.path}" />      </target>       <!-- 编译 -->    <target name="compile" depends="init" >          <javac destdir="${build.path}" debug="true" srcdir="src"  encoding="utf-8" includeantruntime="false" >              <classpath refid="compile.classpath"/>          </javac>          <echo message="Compile Finished!"></echo>    </target>      <!-- 打包 -->    <target name="war" depends="compile">        <copydir  dest="WebRoot/WEB-INF/classes" http://www.mamicode.com/src="src" excludes="**/*.java" />        <war destfile="${output.path}/E-Learning.war" webxml="WebRoot/WEB-INF/web.xml" >              <fileset dir="WebRoot"/>              <classes dir="${build.path}"/>          </war>        <echo message="Package Finished!"></echo>    </target>        <!-- 部署 -->    <target name="deploy" depends="war">        <delete dir="${tomcat.home}/webapps/E-Learning" />        <delete dir="${tomcat.home}/webapps/E-Learning.war" />        <copy todir="${tomcat.home}/webapps">            <fileset file="${output.path}/E-Learning.war" />        </copy>        <echo message="Deploy Finished!"></echo>    </target>     <!-- 清理 -->    <target name="clean" depends="deploy">          <delete dir="${build.path}" />          <delete dir="build" />          <delete dir="${output.path}" />          <echo message="Clean Finished!"></echo>    </target>  </project>

  

Ant自动构建