根据Eclipse SVN changelog使用ANT自动打增量包
1、获取changeLog
用eclipseSVN的插件功能查看history。

将日志文件导出到本地文件svn_change.log,格式如下
r63 | xiaodaoshi | 2014-08-08 18:01:36 CST
Changed paths:
M /root/Testproject/ANT_DEMO/demo/src/com/csdn/common/util/StringUtil.java
M /root/Testproject/ANT_DEMO/demo/src/com/csdn/service/First.java
A /root/Testproject/ANT_DEMO/demo/src/com/csdn/service/Second.java
M /root/Testproject/ANT_DEMO/demo/src/com/csdn/service/Third.java
M /root/Testproject/ANT_DEMO/demo/webapps/demo/welcome/welcome.jsp
M /root/Testproject/ANT_DEMO/demo/webapps/demo/images/welcome.png <description>测试</description>
xds9527 ----------------------------------------------------------------------------
2、ANT脚本的编写,基本原理是读取changeLog.txt,首先过滤将注释,提交人..等等不需要的信息过滤掉。导入到新文件patch.log。在读取此文件根据正则表达式处理没效的目录,在替换成真实编译后的classes目录。将.java替换成*.class后缀。*是为了通配符。匹配内部类。如何根据文件复制到新目录下。在根据此打包。就基本完成功能了。
无效信息过滤后文件内容
webapps/demo/WEB-INF/classes/com/csdn/common/util/StringUtil*.class
webapps/demo/WEB-INF/classes/com/csdn/service/First*.class
webapps/demo/WEB-INF/classes/com/csdn/service/Second*.class
webapps/demo/WEB-INF/classes/com/csdn/service/Third*.class
webapps/demo/welcome/welcome.jsp
webapps/demo/images/welcome.png
下面是完整的ANT脚本
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="patch_without_compile">
<!-- TLBADX 项目 -->
<property name="project.name" value="demo" />
<tstamp><format property="date.today" pattern="yyyyMMdd" /></tstamp>
<!-- svn提交change日志 -->
<property name="change.log" value="./changeLog.txt" />
<!-- 补丁包所在目录 -->
<property name="build.dir" value="./release" />
<!-- 读取svn日志提取出新增和修改文件 获取补丁包包含的文件 -->
<property name="patch.includesfile" value="${build.dir}/patchfiles.txt" />
<!-- 补丁包名称 -->
<property name="dest.zip" value="${project.name}_${date.today}_patch.zip" /> <!-- - - - - - - - - - target:从svn日志中,取出checkin文件 - - - - - - - - - -->
<target name="patchfile" depends="init" description="处理 svn_changge 日志 ">
<!-- 去掉 SVN日志中的注释,只保留Added和Modified记录 -->
<concat destfile="${patch.includesfile}" append="false" force="true">
<fileset file="${change.log}" />
<filterchain>
<containsregex byline="true" pattern="^([\s]+)(?:A|M)([\s]+)(.+)$" replace="\3" />
</filterchain>
</concat> <!-- 将src目录替换为classes目录 主要针对提交的代码 -->
<replaceregexp file="${patch.includesfile}" byline="true">
<!-- (?:X) X作为非捕获组 相当于java的group概念 提取出代码的相对路径 -->
<regexp pattern="^/.+/(?:src)/(.+)\..+$" />
<substitution expression="webapps/toolbar/WEB-INF/classes/\1*.class" />
</replaceregexp>
<!-- 替换掉WebRoot/前面的路径 主要针对提交.js .css 等图片页面文件 -->
<replaceregexp file="${patch.includesfile}" byline="true">
<!-- (?=X) 从句子前面读取 如果X前面为空直接略过。 前面不为空的执行替换操作 -->
<regexp pattern="^/.+/(?=webapps/)" />
<substitution expression="" />
</replaceregexp>
</target> <!-- - - - - - - - - - target:package - - - - - - - - - -->
<target name="package" description="补丁包">
<delete dir="${build.dir}/webapps" />
<copy todir="${build.dir}" overwrite="true">
<fileset dir="." includesfile="${patch.includesfile}" />
</copy> <delete file="${build.dir}/${dest.zip}" />
<zip destfile="${build.dir}/${dest.zip}" compress="true">
<zipfileset prefix="webapps" dir="${build.dir}/webapps">
<include name="**" />
</zipfileset>
</zip>
</target> <!-- - - - - - - - - - target:release without compile - - - - - - - - - -->
<target name="patch_without_compile" depends="patchfile, package" description="--> release">
<echo>补丁包打包结束</echo>
</target> <!-- - - - - - - - - -target: init - - - - - - - - - -->
<target name="init" depends="clean">
<mkdir dir="${build.dir}"/>
</target>
<!-- - - - - - - - - -target: clean - - - - - - - - - -->
<target name="clean">
<delete dir="${build.dir}" />
</target> </project>
这样的话获取版本changeLog.txt,执行ANT脚本。在release目录下就会生成补丁包了。
根据Eclipse SVN changelog使用ANT自动打增量包的更多相关文章
- ant+svn+tomcat实现项目自动部署
因工作需要,研究并实现了 ant+svn+tomcat实现项目自动部署,其中参考了下面文章:http://www.cnblogs.com/taoweiji/p/3700915.html jar包需要e ...
- eclipse svn插件 设置自动加锁相关
eclipse svn插件 设置自动加锁相关 Subclipse 1.10.9 发布,改进说明:SVNKit 1.8.8Exception proof repository sorter. (1616 ...
- linux(以ubuntu为例)下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
原创,转载请注明:http://www.cnblogs.com/ycxyyzw/p/4555328.html 之前写过一篇<windows下Android利用ant自动编译.修改配置文件.批量 ...
- windows下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
原创文章,转载请注明:http://www.cnblogs.com/ycxyyzw/p/4535459.html android 程序打包成apk,如果在是命令行方式,一般都要经过如下步骤: 1.用a ...
- Andorid进阶7—— Ant自动编译打包&发布 android项目
http://www.cnblogs.com/tt_mc/p/3891546.html Eclipse用起来虽然方便,但是编译打包android项目还是比较慢,尤其将应用打包发布到各个渠道时,用Ecl ...
- Ant自动打包
在ant的官网http://ant.apache.org进行下载后apache-ant-1.8.2包 解压(存放的路径不要有中文字符) 把ant里的lib设置到环境变量:E:\Android\apac ...
- eclipse svn分支与合并操作
以前做项目的时候没有用过svn的分支合并操作,今天用到了,刚开始还真不会啊.最后查了下就是这么的方便.专门记录下来. 原文来自:http://blog.csdn.net/lisq037/article ...
- Eclipse SVN插件与TortoiseSVN的对应关系及下载链接
Eclipse SVN 插件与TortoiseSVN对应关系 Eclipse 3.2/Callisto, 3.3/Europa, 3.4/Ganymede, 3.5/Galileo, 3.6/Heli ...
- Ant自动编译打包&发布 android项目
Eclipse用起来虽然方便,但是编译打包android项目还是比较慢,尤其将应用打包发布到各个渠道时,用Eclipse手动打包各种渠道包就有点不切实际了,这时候我们用到Ant帮我们自动编译打包了. ...
随机推荐
- SQL Server 备份和还原全攻略
原文:SQL Server 备份和还原全攻略 一.知识点 完全备份: 备份全部选中的文件夹,并不依赖文件的存档属性来确定备份那些文件.(在备份过程中,任何现有的标记都被清除,每个文件都被标记为已备份, ...
- google面试题,男孩男女比例?
Google面试题: 在一个重男轻女的国家里,每一个家庭都想生男孩.假设他们生的孩子是女孩.就再生一个,直到生下的是男孩为止,这种国家.男女比例会是多少? 答案:1:1 分析: 出生男女概率是50% ...
- C#关于HttpClient的统一配置(一)
public class BaseHttpClient { protected string contentType; public BaseHttpClient() { this.contentTy ...
- linux_shell_拆分文件_多进程脚本
[需求场景]:一个10000w行的文件处理 ,多进程处理 比如启动100个进程同时处理. [方法]:拆分文件(split) ,制作shell脚本 执行后台进程 [demo]: 假设处理程序为 ...
- Android_显示器本身被卸载应用程序
1.经jni实现功能 //LOG宏定义 #define LOG_INFO(tag, msg) __android_log_write(ANDROID_LOG_INFO, tag, msg) #defi ...
- JS里写入(混写)php asp
原文:JS里写入(混写)php asp JS里写入(混写)php 方法1:<Br> <script language="javascript"> docum ...
- c# 自定义数据类型
定义引用类型用 class ,值类型 用 struct ,涉及数据转换就用 上一篇的方法做 ,涉及 泛型就用 in 关键字 不用 in interface IContravariant<A& ...
- HDU 4324 Triangle LOVE 拓扑排序
Problem Description Recently, scientists find that there is love between any of two people. For exam ...
- android 当目录路径从n层按back键退回到n-19层的时候,file manager自己主动退出
当目录路径从n层按back键退回到n-19层的时候,file manager自己主动退出,比方在63层按back 键退回到44层的时候,file manager自己主动退出. 1.FileMana ...
- windows phone开发-Webbrowser使用技巧
原文:windows phone开发-Webbrowser使用技巧 5月份开发了脸萌WP版,其中需要使用web技术来绘制图像,于是就使用了原生webbrowser控件.在使用webbrowser co ...