<?xml version="1.0" encoding="utf-8"?>
<!-- 该ant直接将编译后的项目部署到tomcat中 -->
<project name="scc" basedir="." default="deploy">
<!-- env指向系统环境变量 -->
<property environment="env" />
<!-- tomcat路径 -->
<property name="tomcat.home" value="${env.TOMCAT_HOME}" />
<!-- 编译后保存路径,直接部署到tomcat\webapps中,这样做必须先停止tomcat -->
<property name="deploy.dir" value="${tomcat.home}\webapps\scc" />
<path id="build.classpath" description="指定编译需要用到的jar包路径">
<fileset dir="${tomcat.home}\lib">
<!-- tomcat中的jar包 -->
<include name="*.jar" />
</fileset>
<fileset dir="${basedir}\WebRoot\WEB-INF\lib">
<!-- 项目lib目录中的jar包 -->
<include name="*.jar" />
</fileset>
</path>
<target name="stop-tomcat" description="停止tomcat">
<exec executable="cmd " dir="${tomcat.home}\bin" failonerror="false">
<arg value="/c" />
<arg value="net stop Tomcat7" />
</exec>
</target>
<target name="prepare" depends="stop-tomcat" description="删除并新建部署项目的目录">
<delete dir="${deploy.dir}" />
<delete dir="${tomcat.home}\work" />
<mkdir dir="${deploy.dir}" />
<echo message=">>>>>>>>>>>>>>>>>>发布目录已经准备好" />
</target>
<target name="copyfile" depends="prepare" description="拷贝必须的文件">
<!-- 拷贝到${deploy.dir} -->
<copy todir="${deploy.dir}">
<!-- ${basedir}\WebRoot中所有文件 -->
<fileset dir="${basedir}\WebRoot">
<!-- 排除WEB-INF文件夹 -->
<exclude name="\WEB-INF\" />
</fileset>
</copy>
<!-- 拷贝到${deploy.dir}\WEB-INF -->
<copy todir="${deploy.dir}\WEB-INF">
<!-- ${basedir}\WebRoot\WEB-INF中所有文件 -->
<fileset dir="${basedir}\WebRoot\WEB-INF">
<!-- 排除classes文件夹 -->
<exclude name="\classes\" />
</fileset>
</copy>
<!-- 拷贝基础配置文件到${deploy.dir}\WEB-INF\classes -->
<copy todir="${deploy.dir}\WEB-INF\classes">
<!-- ${basedir}\config_sys中所有文件 -->
<fileset dir="${basedir}\config_sys" />
<!-- ${basedir}\sqlMap中所有文件 -->
<fileset dir="${basedir}\sqlMap" />
</copy>
<echo message=">>>>>>>>>>>>>>>>>>项目文件已拷贝完成" />
</target>
<target name="compile" depends="copyfile" description="编译并部署到tomcat">
<!-- srcdir:源文件所在的目录,destdir:编译后的class文件存放的目录-->
<javac srcdir="${basedir}\src" destdir="${deploy.dir}\WEB-INF\classes" fork="true" memorymaximumsize="512m" encoding="UTF-8" includeAntRuntime="false">
<!-- 指定编译所需jar包 -->
<classpath refid="build.classpath" />
</javac>
<echo message=">>>>>>>>>>>>>>>>>>项目class文件编译完成,并已部署到tomcat" />
</target>
<target name="start-tomcat" depends="compile" description="启动tomcat">
<exec executable="cmd" dir="${tomcat.home}\bin" failonerror="false">
<arg value="/c" />
<arg value="net start Tomcat7" />
</exec>
</target>
<target name="deploy" depends="start-tomcat" description="部署">
<echo message="###################################################" />
<echo message="#####################部署完成######################" />
<echo message="###################################################" />
</target>
</project>
windows2003中SVN服务器异机同步、自动部署Java项目全流程
5星 · 超过95%的资源 需积分: 13 81 浏览量
2013-04-26
17:23:27
上传
评论 2
收藏 1.04MB ZIP 举报
栩言
- 粉丝: 2
- 资源: 13
- 1
- 2
前往页