码迷,mamicode.com
首页 > 其他好文 > 详细

Ant自动构建

时间:2014-11-09 11:01:20      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:des   blog   ar   java   sp   文件   div   log   ef   

Ant+jenkins+tomcat

<project name="buildWar" default="clean">  
    <property name="tomcat.home" value="/opt/tomcat" />
    <property name="build.path" value="build/classes" />
    <property name="output.path" value="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" 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自动构建

标签:des   blog   ar   java   sp   文件   div   log   ef   

原文地址:http://www.cnblogs.com/libaoting/p/4084668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!