搭建环境参考了:
http://blog.csdn.net/neilalexander/article/details/38950097
主要介绍一下,遇到的问题:
首先需要安装ANT,确认是否安装完整直接进行 ant输入就可以了
d:回车
cd apach* 回车
cd bin 回车
ant 回车

这样表示ant安装完成了,也可以用 ant -version 判定版本信息

需要添加几个包

在当前目录下创建一个文件夹svnant_lib

注意一下,你的properties路径的后面不要留有空格
注意xml中 ,有一句一个导入的包,做增量和减量的时候需要用到这个jar,所以你的路径要和自己写的一致,你可以用参考链接提供的,或者自己写一个

在cmd中执行,有用到了JDT去编译JAVA文件,之前在eclipse中一直无法编译,未知
图中第一行是输入命令,可以看到你的SVN登录信息,去找到SVN的版本和检出动作


图中有告诉了一共有693个文件,有147个class文件的移动,最后打包成了war包,这个是全量,通过修改
最后执行的参数就可以对应不同的打包方式了

这边3个名称就是对应的 执行方式了
附上BUILD.XML
<?xml version="1.0" encoding="UTF-8" ?>
<project default="svn_war" basedir=".">
<property file="build.properties" />
<!-- svn 比较项目最新路径 -->
<property name="svn.url" value="${svn._url}" />
<!-- svn 比较项目的新版本 -->
<property name="svn.new_revision" value="${svn.new_revision}" />
<!-- svn 比较项目的旧路径-->
<property name="bak.svn.url" value="${bak.svn._url}" />
<!-- svn 比较项目的旧版本 -->
<property name="svn.old_revision" value="${svn.old_revision}" />
<property name="svn.username" value="${svn.username}" />
<property name="svn.password" value="${svn.password}" />
<!-- 项目名称 -->
<property name="webapp" value="${webapp.name}" />
<!-- 目标项目的Web 名称(WEB-INF上一级的目录名称) -->
<property name="webroot" value="${web.root}" />
<!-- svn改动文件列表信息 -->
<property name="compare.path.file" value="${increment.file.path}/${webapp}_${increment.file}" />
<!-- 减量文件编译后文件列表信息 -->
<property name="decrement.file.list" value="${export.decrement_files_list.path}/${webapp}_${export.decrement_files_list}" />
<!-- svn导出包存放目录 -->
<property name="export.svn" location="${export.svn}/${webapp}" />
<!-- svn导出/切出旧版本文件存放目录 -->
<property name="bak_dest.path" location="${export.bak_dest}/${webapp}" />
<!-- svn导出/切出旧版本文件编译后存放目录 -->
<property name="bak_dist.path" location="${export.bak_dist}/${webapp}" />
<!-- svn导出/切出新版本文件存放目录 -->
<property name="dest.path" location="${export.dest}/${webapp}" />
<!-- svn导出/切出文件编译后存放目录 -->
<property name="dist.path" location="${export.dist}/${webapp}" />
<!-- svn增量文件保存目录 -->
<property name="increment.dest.path" location="${export.increment_dest}/${webapp}" />
<!-- svn增量文件编译后保存目录 -->
<property name="increment.dist.path" location="${export.increment_dist}/${webapp}" />
<!-- svn减量文件保存目录 -->
<property name="decrement.dest.path" location="${export.decrement_dest}/${webapp}" />
<!-- svn减量文件编译后保存目录 -->
<property name="decrement.dist.path" location="${export.decrement_dist}/${webapp}" />
<!-- 利用jdt编译class 解决泛型不能转换的问题 需要将
jdtCompilerAdapter.jar
org.eclipse.jdt.compiler.tool_1.0.1.v_793_R33x.jar
org.eclipse.jdt.core_3.3.3.v_793_R33x.jar
org.eclipse.jdt.debug.ui_3.2.102.v20071002_r332.jar
复制到ant_home/lib目录下
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
-->
<path id="svnant.classpath">
<fileset dir="${svnant.classpath}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="buildpath">
<fileset dir="${dest.path}">
<include name="**/lib/*.jar" />
</fileset>
<fileset dir="${jdk.classpath}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="buildpath_old">
<fileset dir="${bak_dest.path}">
<include name="**/lib/*.jar" />
</fileset>
<fileset dir="${jdk.classpath}">
<include name="**/*.jar" />
</fileset>
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />
<svnSetting id="svn.settings" javahl="false" svnkit="true" username="${svn.username}" password="${svn.password}" failonerror="true" />
<target name="init" description="init clean dirs">
<echo message="${svn.username}" />
<echo message="${svn.password}" />
<echo message="${webapp}" />
<echo message="${webroot}" />
<echo message="${compare.path.file}" />
<delete dir="${bak_dest.path}" failonerror="false" deleteonexit="true" />
<delete dir="${bak_dist.path}" failonerror="false" deleteonexit="true" />
<delete dir="${dest.path}" failonerror="false" deleteonexit="true" />
<delete dir="${dist.path}" failonerror="false" deleteonexit="true" />
<delete file="${compare.path.file}" failonerror="false" />
<delete file="${decrement.file.list}" failonerror="false" />
<delete dir="${increment.dest.path}" failonerror="false" deleteonexit="true" />
<delete dir="${increment.dist.path}" failonerror="false" deleteonexit="true" />
<delete dir="${decrement.dest.path}" failonerror="false" deleteonexit="true" />
<delete dir="${decrement.dist.path}" failonerror="false" deleteonexit="true" />
</target>
<!-- that is to test i svnant is available //-->
<target name="tool-available" depends="init">
<echo message="run task test svnant is available">
</echo>
<available resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" property="available.svnant" />
<echo message="SVN-ANT is available = ${available.svnant}">
</echo>
</target>
<!-- 比较差异 增量文件 -->
<target name="diff" description="diff/compare project">
<svn refid="svn.settings">
<diffSummarize oldUrl="${bak.svn.url}" oldTargetRevision="${svn.old_revision}" newUrl="${svn.url}" newTargetRevision="${svn.new_revision}" outFile="${compare.path.file}" recurse="true" />
</svn>
</target>
<!-- 下载 切成 导出 服务器上最新代码 -->
<target name="checkout" description="checkout/export project code ${svn_url} ">
<echo message="checkout/export project code ${svn_url} - ${svn_revision} to ${dest_path}">
</echo>
<svn refid="svn.settings">
<export srcUrl="${svn_url}" destPath="${dest_path}" revision="${svn_revision}" force="true" />
</svn>
</target>
<!-- javac编译 -->
<target name="compile">
<echo>compile ${dest.path} ......</echo>
<delete dir="${dist.path}" failonerror="false" deleteonexit="true" />
<mkdir dir="${dist.path}/classes" />
<javac nowarn="true" debug="${javac.debug}" debuglevel="${javac.debuglevel}" destdir="${dist.path}/classes" source="${javac.source}" target="${javac.target}" encoding="utf-8" fork="true" memoryMaximumSize="512m" includeantruntime="false">
<src path="${dest.path}/src" />
<!--
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:deprecation"/>
<compilerarg value="-Xlint"/>
-->
<classpath refid="buildpath" />
</javac>
</target>
<!-- 利用JDT编译 -->
<target name="compile_jdt">
<echo>compile ${dest_path} ......</echo>
<delete dir="${dist_path}" failonerror="false" deleteonexit="true" />
<mkdir dir="${dist_path}/classes" />
<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" nowarn="true" debug="${javac.debug}" debuglevel="${javac.debuglevel}" destdir="${dist_path}/classes" source="${javac.source}" target="${javac.target}" encoding="utf-8" fork="true" memoryMaximumSize="1024m" includeantruntime="false">
<src path="${dest_path}/src" />
<classpath refid="${jdt_buildpath}" />
</javac>
</target>
<!-- 利用JDT编译SVN 最新项目 -->
<target name="compile_svn">
<!-- 回调任务 -->
<antcall target="compile_jdt">
<param name="dest_path" value="${dest.path}" />
<param name="dist_path" value="${dist.path}" />
<param name="jdt_buildpath" value="buildpath" />
</antcall>
</target>
<!-- 将全部项目的class 建立jar包(新版本) -->
<target name="jar" depends="compile_svn">
<jar destfile="${dest.path}/${web.root}/WEB-INF/lib/${webapp}.jar" level="9" compress="true" encoding="utf-8" basedir="${dist.path}/classes">
<manifest>
<attribute name="Implementation-Version" value="Version: 2.2" />
</manifest>
</jar>
</target>
<!-- 利用JDT编译SVN 旧版本项目 -->
<target name="compile_svn_old">
<!-- 回调任务 -->
<antcall target="compile_jdt">
<param name="dest_path" value="${bak_dest.path}" />
<param name="dist_path" value="${bak_dist.path}" />
<param name="jdt_buildpath" value="buildpath_old" />
</antcall>
</target>
<!-- 将全部项目的class 建立jar包(旧版本) -->
<target name="jar_old" depends="compile_svn_old">
<jar destfile="${bak_dest.path}/${web.root}/WEB-INF/lib/${webapp}.jar" level="9" compress="true" encoding="utf-8" basedir="${bak_dist.path}/classes">
<manifest>
<attribute name="Implementation-Version" value="Version: 2.2" />
</manifest>
</jar>
</target>
<!-- 导出增量和减量文件 -->
<target name="increment" depends="diff">
<java classname="com.yubo.util.ExportIncrementFiles" classpath="${svnant.classpath}/lib/increment.export.jar" fork="true">
<arg value="${compare.path.file}" />
<arg value="${dest.path}/" />
<arg value="${increment.dest.path}/" />
<arg value="${bak_dest.path}/" />
<arg value="${decrement.dest.path}/" />
</java>
</target>
<!-- 检查增量文件夹源文件夹是否存在 -->
<target name="increment_dir_check">
<available property="increment_dir_check.value" file="${increment.dest.path}/src" type="dir">
</available>
</target>
<!-- 利用JDT编译增量文件 -->
<target name="compile_increment" depends="increment_dir_check" if="increment_dir_check.value">
<antcall target="compile_jdt">
<param name="dest_path" value="${increment.dest.path}" />
<param name="dist_path" value="${increment.dist.path}" />
<param name="jdt_buildpath" value="buildpath" />
</antcall>
</target>
<!-- 检查减量文件夹源文件夹是否存在 -->
<target name="decrement_dir_check">
<available property="decrement_dir_check.value" file="${decrement.dest.path}/src" type="dir">
</available>
</target>
<!-- 利用JDT编译减量文件 -->
<target name="compile_decrement" depends="decrement_dir_check" if="decrement_dir_check.value">
<antcall target="compile_jdt">
<param name="dest_path" value="${decrement.dest.path}" />
<param name="dist_path" value="${decrement.dist.path}" />
<param name="jdt_buildpath" value="buildpath_old" />
</antcall>
</target>
<!-- 全部打包 -->
<target name="war">
<echo>create war file.......</echo>
<copy todir="${dist_path}" failonerror="false">
<fileset dir="${dest_path}/${webroot}" includes="**" />
</copy>
<move todir="${dist_path}/WEB-INF/classes" failonerror="false">
<fileset dir="${dist_path}/classes" />
</move>
<copy todir="${dist_path}/WEB-INF/classes" failonerror="false">
<fileset dir="${dest_path}/src/" includes="**/*.xml, **/*.properties, **/*.xsd" />
</copy>
<!--得到当前日期-->
<tstamp>
<format property="DSTAMP" pattern="yyyyMMdd" locale="zh" />
<format property="TSTAMP" pattern="HHmmss" locale="zh" />
</tstamp>
<war destfile="${export.svn}/${webapp}_${DSTAMP}_${TSTAMP}.war" basedir="${dist_path}" webxml="${dist_path}/WEB-INF/web.xml" />
</target>
<!-- 移动减量包其他文件 -->
<target name="create_decrement">
<echo>create decrement file.......</echo>
<copy todir="${decrement.dist.path}" failonerror="false">
<fileset dir="${decrement.dest.path}/${webroot}" includes="**" />
</copy>
<move todir="${decrement.dist.path}/WEB-INF/classes" failonerror="false">
<fileset dir="${decrement.dist.path}/classes" />
</move>
<copy todir="${decrement.dist.path}/WEB-INF/classes" failonerror="false">
<fileset dir="${decrement.dest.path}/src/main/resources" includes="**/*.xml, **/*.properties, **/*.xsd" />
</copy>
</target>
<!-- 移动增量包其他文件 -->
<target name="create_increment">
<echo>create increment file.......</echo>
<copy todir="${increment.dist.path}" failonerror="false">
<fileset dir="${increment.dest.path}/${webroot}" includes="**" />
</copy>
<move todir="${increment.dist.path}/WEB-INF/classes" failonerror="false">
<fileset dir="${increment.dist.path}/classes" />
</move>
<copy todir="${increment.dist.path}/WEB-INF/classes" failonerror="false">
<fileset dir="${increment.dest.path}/src/main/resources" includes="**/*.xml, **/*.properties, **/*.xsd" />
</copy>
</target>
<!--检出新版本-->
<target name="checkout_new">
<antcall target="checkout">
<param name="dest_path" value="${dest.path}" />
<param name="svn_url" value="${svn.url}" />
<param name="svn_revision" value="${svn.new_revision}" />
</antcall>
</target>
<!--检出旧版本-->
<target name="checkout_old">
<antcall target="checkout">
<param name="dest_path" value="${bak_dest.path}" />
<param name="svn_url" value="${bak.svn.url}" />
<param name="svn_revision" value="${svn.old_revision}" />
</antcall>
</target>
<!-- 全部打包 -->
<target name="war_svn">
<antcall target="war">
<param name="dest_path" value="${dest.path}" />
<param name="dist_path" value="${dist.path}" />
</antcall>
</target>
<!-- 全部打包 -->
<target name="war_increment">
<copy todir="${increment.dist.path}/WEB-INF" file="${dest.path}/${webroot}/WEB-INF/web.xml" />
<antcall target="war">
<param name="dest_path" value="${increment.dest.path}" />
<param name="dist_path" value="${increment.dist.path}" />
</antcall>
</target>
<!-- 检查减量文件列表文件夹是否存在 -->
<target name="output_decrement_dir_check">
<available property="output_decrement_dir_check.value" file="${decrement.dist.path}" type="dir">
</available>
</target>
<!-- 输出减量文件列表 -->
<target name="output_decrement" depends="output_decrement_dir_check" if="output_decrement_dir_check.value">
<path id="decrement_file_paths">
<fileset dir="${decrement.dist.path}">
</fileset>
</path>
<pathconvert property="decrement_file_pathSum" pathsep="${line.separator}">
<path refid="decrement_file_paths">
</path>
</pathconvert>
<echo message="${decrement_file_pathSum}" file="${decrement.file.list}">
</echo>
</target>
<!-- svn 全量包 -->
<target name="svn_war" depends="tool-available, checkout_new, compile_svn, war_svn" />
<!-- 增量包+减量文件夹 -->
<target name="increment_war" depends="tool-available, checkout_old, checkout_new, increment, jar_old, jar, compile_increment, compile_decrement, war_increment, create_decrement" />
<!-- 增量文件夹+减量文件夹 -->
<target name="patch_folder" depends="tool-available, checkout_old, checkout_new, increment, jar_old, jar, compile_increment, compile_decrement, create_increment, create_decrement, output_decrement" />
</project>
附上 build.properties
#项目名称(这个配置将决定导出的文件夹名字和war包名字) webapp.name=mobile #目标项目的Web 名称(WEB-INF上一级的目录名称) web.root=WebContent #svn项目新版本的路径 svn._url=XXXXXXXXXXXXXXXXXXXXXXX #svn新版本的版本号 svn.new_revision=188 #svn项目旧版本的路径 bak.svn._url=XXXXXXXXXX #svn旧版本的版本号 svn.old_revision=1 svn.username=XXXXX svn.password=XXXXXXXXXX #比较文件目录 increment.file.path=D:/svnAnt #比较文件名 increment.file=patch.txt #svn导出包存放目录 export.svn=D:/svnAnt #svn导出/切出旧版本文件存放目录 export.bak_dest=D:/svnAnt/bak_dest #svn导出/切出旧版本文件编译后存放目录 export.bak_dist=D:/svnAnt/bak_dist #svn导出/切出新版本文件存放目录 export.dest=D:/svnAnt/dest #svn导出/切出文件编译后存放目录 export.dist=D:/svnAnt/dist #svn增量文件保存目录 export.increment_dest=D:/svnAnt/increment_dest #svn增量文件编译后保存目录 export.increment_dist=D:/svnAnt/increment_dist #svn减量文件保存目录 export.decrement_dest=D:/svnAnt/decrement_dest #svn减量文件编译后保存目录 export.decrement_dist=D:/svnAnt/decrement_dist #减量文件编译后文件列表信息目录 export.decrement_files_list.path=D:/svnAnt #减量文件编译后文件列表信息文件名 export.decrement_files_list=decrement_files_list.txt #svnAnt类库的父级路径 svnant.classpath=D:/apache-ant-1.9.6 #jdk类库的父级路径 jdk.classpath=C:/Program Files (x86)/Java/jdk1.7.0_13 javac.debuglevel=source,lines,vars javac.target=1.7 javac.source=1.7 javac.debug=true