利用SVN实现增量打包
来源:互联网 发布:个人如何开通淘宝直播 编辑:程序博客网 时间:2024/06/01 10:39
好神奇,今天学会了使用Eclipse配合SVN实现项目增量打包,来看看。
环境:
Eclipse或MyEclipse
项目已经通过SVN共享
以下是转载内容:
很多情况下,项目是不允许全量发布的,所以你得把有做修改的文件一个个挑出来,如果有成千上百的文件,你是不是要头大了? 以下方法应该可以让你得到解救!前提是你是用装有svn plugin的eclipse上做开发。
第一步,用svn生成项目的补丁文件。
选中你需要增量升级的文件,点击完成。
运行如下代码
<span style="font-size:12px;">package verysoft.freepath;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;public class FreePatchUtil {public static String patchFile="D:/patch.txt";//补丁文件,由eclipse svn plugin生成public static String projectPath="D:/workspace/FordClubJeeCms";//项目文件夹路径public static String webContent="WebContent";//web应用文件夹名public static String classPath="D:/workspace/FordClubJeeCms/build";//class存放路径public static String desPath="C:/Users/xuwen/Desktop/update_pkg";//补丁文件包存放路径public static String version="20140711";//补丁版本/** * @param args * @throws Exception */public static void main(String[] args) throws Exception {copyFiles(getPatchFileList());}public static List<String> getPatchFileList() throws Exception{List<String> fileList=new ArrayList<String>();FileInputStream f = new FileInputStream(patchFile); BufferedReader dr=new BufferedReader(new InputStreamReader(f,"utf-8"));String line;while((line=dr.readLine())!=null){ if(line.indexOf("Index:")!=-1){line=line.replaceAll(" ","");line=line.substring(line.indexOf(":")+1,line.length());fileList.add(line);}} return fileList;}public static void copyFiles(List<String> list){for(String fullFileName:list){if(fullFileName.indexOf("src/")!=-1){//对源文件目录下的文件处理String fileName=fullFileName.replace("src","");fullFileName=classPath+fileName;if(fileName.endsWith(".java")){fileName=fileName.replace(".java",".class");fullFileName=fullFileName.replace(".java",".class");}String tempDesPath=fileName.substring(0,fileName.lastIndexOf("/"));String desFilePathStr=desPath+"/"+version+"/WEB-INF/classes"+tempDesPath;String desFileNameStr=desPath+"/"+version+"/WEB-INF/classes"+fileName;File desFilePath=new File(desFilePathStr);if(!desFilePath.exists()){desFilePath.mkdirs();}copyFile(fullFileName, desFileNameStr);System.out.println(fullFileName+"复制完成");}else{//对普通目录的处理String desFileName=fullFileName.replaceAll(webContent,"");fullFileName=projectPath+"/"+fullFileName;//将要复制的文件全路径String fullDesFileNameStr=desPath+"/"+version+desFileName;String desFilePathStr=fullDesFileNameStr.substring(0,fullDesFileNameStr.lastIndexOf("/"));File desFilePath=new File(desFilePathStr);if(!desFilePath.exists()){desFilePath.mkdirs();}copyFile(fullFileName, fullDesFileNameStr);System.out.println(fullDesFileNameStr+"复制完成");}}}private static void copyFile(String sourceFileNameStr, String desFileNameStr) {File srcFile=new File(sourceFileNameStr);File desFile=new File(desFileNameStr);try {copyFile(srcFile, desFile);} catch (IOException e) {e.printStackTrace();}}public static void copyFile(File sourceFile, File targetFile) throws IOException { BufferedInputStream inBuff = null; BufferedOutputStream outBuff = null; try { // 新建文件输入流并对它进行缓冲 inBuff = new BufferedInputStream(new FileInputStream(sourceFile)); // 新建文件输出流并对它进行缓冲 outBuff = new BufferedOutputStream(new FileOutputStream(targetFile)); // 缓冲数组 byte[] b = new byte[1024 * 5]; int len; while ((len = inBuff.read(b)) != -1) { outBuff.write(b, 0, len); } // 刷新此缓冲的输出流 outBuff.flush(); } finally { // 关闭流 if (inBuff != null) inBuff.close(); if (outBuff != null) outBuff.close(); } }}</span>
注意,以下部份请按照实际情况填写
<span style="font-size:12px;">public static String patchFile="D:/patch.txt";//补丁文件,由eclipse svn plugin生成public static String projectPath="D:/workspace/FordClubJeeCms";public static String webContent="WebContent";//web应用文件夹名public static String classPath="D:/workspace/FordClubJeeCms/build";//class存放路径public static String desPath="C:/Users/xuwen/Desktop/update_pkg";//补丁文件包存放路径public static String version="20140711";//补丁版本</span>
好了,运行后得到结果
如果有多个人都修改了代码,那么每个人在提交代码之前先按第一步生成补丁文件再提交。当所有人都提交代码后,在一台电脑上更新所有代码,再在这台电脑上用以上代码运行所有人生成的补丁文件即可。
更多技术文章,请关注微信公众号zssorin,或扫描下方二维码:
0 1
- 利用SVN实现增量打包
- 利用svn的补丁文件打包生成增量文件的两种方法
- eclipse实现JavaWeb应用增量打包
- eclipse实现JavaWeb项目 增量打包
- eclipse实现JavaWeb应用增量打包
- eclipse实现JavaWeb应用增量打包
- 利用svn 日志、eclipse 增量发包,非常简单!
- 利用Gradle实现多包名打包
- java 增量打包工具
- Git增量更新打包
- 利用INFORMATICA实现增量数据的抽取与加载
- 利用Hbase的coprocessor实现增量式Apriori算法
- ODI使用技巧_01利用变量实现增量抽取
- ODI使用技巧_01利用变量实现增量抽取
- Kettle:利用设置变量(时间戳)实现数据增量更新
- SVN增量备份方案
- SVN导出增量包
- SVN服务器增量备份
- 样本均值的特征与分布
- 实现支持2^n字节对齐分配的malloc和free函数
- nexus私服学习总结
- RequireJS:一款优秀的AMD模块加载器
- 68. Text Justification
- 利用SVN实现增量打包
- Java Web错误页面
- 树状数组入门之POJ 2352 Star
- 欢迎使用CSDN-markdown编辑器
- eclipse F3可以看到class的定义,但是编辑器里有叉叉,refers to type "", 类型不匹配
- swift 关于 CocoaPods引入Alamofire报警告问题
- Unity Shaders——屏幕特效混合模式(Blend mode with screen effects)
- Hadoop错误笔记
- eclipse 设置全部的背景颜色