eclipse实现JavaWeb应用增量打包
很多情况下,项目是不允许全量发布的,所以你得把有做修改的文件一个个挑出来,如果有成千上百的文件,你是不是要头大了? 以下方法应该可以让你得到解救!前提是你是用装有svn plugin的eclipse上做开发。
第一步,用svn生成项目的补丁文件。

选中你需要增量升级的文件,点击完成。

运行如下代码
- 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();
- }
- }
- }
注意,以下部份请按照实际情况填写
- 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";//补丁版本
好了,运行后得到结果

如果有多个人都修改了代码,那么每个人在提交代码之前先按第一步生成补丁文件再提交。当所有人都提交代码后,在一台电脑上更新所有代码,再在这台电脑上用以上代码运行所有人生成的补丁文件即可。
eclipse实现JavaWeb应用增量打包的更多相关文章
- 四、使用Maven和使用Eclipse构建javaWeb项目
环境前边已经搭建过了,我们就再弄了. 1.使用Maven构建javaWeb项目 (1).键入以下命令: $ mvn archetype:generate -DgroupId=com.holytax.w ...
- eclipse 将javaWeb项目转化成maven项目
eclipse 将javaWeb项目转化成maven项目 CreateTime--2018年4月18日16:04:18 Author:Marydon 1.首先,maven项目的标准目录 2.web ...
- Eclipse开发JavaWeb程序报Server Tomcat v7.0 at localhost was unable to start
出处:http://www.javaweb1024.com/info/582.jspx 原因重现: Eclipse开发JavaWeb程序,启动Servers的Tomcat服务器,突然跳出弹出框,内容显 ...
- 使用Eclipse进行Javaweb项目开发时,如何设置外置浏览器Chrome
使用Eclipse开发Javaweb项目时,在Eclipse中显示页面不是很好,那么如何让它自动打开外置浏览器呢?操作如下
- 增量打包DOC版
压缩zip的命令有的系统没有的自己去下载一个,否则关闭压缩zip的命令. 有需要的自行更改,这是满足我需求的. 执行 publish.bat 即可,当然需要将文件清单写好放在 resources.tx ...
- Eclipse里面的Maven项目打包(Maven build)
eclipse里面执行maven build打包的时候,如何设置参数? 主要就是设置一个goals
- Eclipse中配置Maven build打包
Eclipse中配置Maven build打包 clean package
- 使用Eclipse搭建JavaWeb开发环境的几个基本问题
Eclipse搭建JavaWeb开发环境 eclipse是一个用于java程序开发的ide软件,tomcat是一个运行javaweb应用的服务器软件,使用eclipse开发javaweb应用的时,首要 ...
- Eclipse导出jar包Unity打包错误
前几天接SDK使用的是Android Studio昨天打开AndroidStudio后自动更新了gradler然后失败了然后AndroidStudio就挂了.就是用之前的方法Eclipse到处jar包 ...
随机推荐
- 生成随机字符串(UUID方法)
这是另一种用UUID生成随机字符串的方法. public class RandomGenerator{ private int length; public void setLength(int le ...
- 3月3日[Go_deep]Populating Next Right Pointers in Each Node
原题:Populating Next Right Pointers in Each Node 简单的链表二叉树增加Next节点信息,没什么坑.不过还是WA了两次,还是有点菜,继续做,另外leetcod ...
- java.util.HashSet源码分析
public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, java. ...
- HTML5 Video(视频)
HTML5 Video(视频) 很多站点都会使用到视频. HTML5 提供了展示视频的标准. 检测您的浏览器是否支持 HTML5 视频: 检测 Web站点上的视频 直到现在,仍然不存在一项旨在网页上显 ...
- 35 个必须有的Bootstrap工具和生成器
Bootstraptor If you think that bootstrap templates are not enough for you, you should go with bootst ...
- cxgrid HyperLink 鼠标显示效果
procedure TForm1.cxGrid1DBTableView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); v ...
- Python在Windows下开发环境配置汇总
最近比较关注学习Python方面的资料和课程,由于Python本身基本都是在Linux下开发,本人windows用习惯了初用Linux各种别扭啊. 下面将我在配置Windows环境下的禁言写出来,与大 ...
- javaweb 在netbeans 上的部署问题
最近用netbeans去部署开发 javaweb程序!现总结一下自己的安装开发过程. 第一,在官网上下载netbeans时,有自带的tomcat,可以直接使用这个服务器,在我这儿这个自带的tomcat ...
- js时间格式的转换
function System_dateInit(value) { if (value != null) { var d = new Date(value); ...
- ExtJs 4.2 treePanel 点击树节点 传送参数到后台(多个参数)
//***********************************************左边树开始********************************************** ...