使用ANT对web项目自动更新代码 编译 打包

在服务器上无法使用eclipse来打包。需采用ant方式
附件中是ant所需要的svn插件 并在ant/lib下面删除:svnjavahl.jar,javasvn.jar
http://panyongzheng.iteye.com/blog/1271184
<?xml version="1.0" encoding="UTF-8"?>
<project name="cim" default="deploy" basedir=".">
	<property name="webapp.name"    value="cim"/>
	<property name="catalina.home" value="C:\apache-tomcat-6.0.35"/>
	<property name="dist.dir" value="C:\Users\shengra\Desktop"/>
	<property name="ant.home" value="C:\apache-ant-1.8.2" />
	<property name="webRoot.dir"    value="${basedir}/${webapp.name}/WebRoot"/>
	<property name="src.dir"      value="${basedir}/${webapp.name}/src"/>
	<property name="lib.dir"    value="${webRoot.dir}/WEB-INF/lib"/>
	<property name="class.dir"    value="${webRoot.dir}/WEB-INF/classes"/>
	<property name="svn.UserName" value="rao.sheng" />
	<property name="svn.UserPassword" value="password" />
	<property name="svn.URL" value="https://ucmdb-int-ld01/svn/ucmdb-int/LeverageUCMDB/trunk/CIM/dev" />
	<property name="svn.Dist" value="${basedir}" />	
	
	<!-- SVN ANT -->
	<path id="ant.svn.classpath">
		<fileset dir="${ant.home}/lib">
			<include name="*.jar" />
		</fileset>
	</path>
	<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask">
		<classpath refid="ant.svn.classpath" />
	</taskdef>
	<target name="checkout" description="checkout full web project">
		<svn username="${svn.UserName}" password="${svn.UserPassword}">
			<checkout url="${svn.URL}" revision="HEAD" destPath="${svn.Dist}" />
		</svn>
	</target>
	
	<path id="compile.classpath">
		<fileset dir="${catalina.home}/lib">
			<include name="*.jar"/>
		</fileset>
		<fileset dir="${lib.dir}">
			<include name="*.jar"/>
		</fileset>
	</path>

	<target name="test">
		<echo>${class.dir}</echo>
	</target>
	
	<target name="clean" depends="checkout">
		<delete dir="${class.dir}"/>
	</target>

	<target name="compile" depends="clean">
		<mkdir dir="${class.dir}"/>
		<javac srcdir="${src.dir}"
			  destdir="${class.dir}">
			<classpath refid="compile.classpath"/>
		</javac>
	</target>

	<target name="copyProperites" depends="clean">
		<copy  todir="${class.dir}">
			<fileset dir="${src.dir}" excludes="**/*.java"/>
		</copy>
	</target>

	<target name="deploy" depends="compile,copyProperites">
		<delete file="${dist.dir}/${webapp.name}.war"/>
		<war destfile="${dist.dir}/${webapp.name}.war">
			<fileset dir="${webRoot.dir}"/>
		</war>
	</target>

</project>

你可能感兴趣的:(Web)