/** 从war包导出文件到增量 */ public void scanWarToZip() { System.out.println("===========从指定压缩文件war、zip、jar 导出到zip文件================="); // 扫描并获取全部excel内容 FilesList fileslist = excellisthelper.createFilesList(); // 排重 fileslist.removeDeuplicate(); int fileCount = 0; SVNRepo svnrepo = SVNRepo.getInstance(); ToZipFile tozipfile = new ToZipFile(svnrepo); // war包的清单 WarFiles warlist = new WarFiles(pv.getProperty("zip.folder"), pv.getProperty("zip.folder.filter")); System.out.println("Loading.." + warlist); // 扫描excel文件的清单 for (FilesListItem oitem : fileslist) { try { // 判断是否目录,目录就不操作 if (PathUtils.isFolder(oitem.getPath())) { System.out.println(" >>>目录不处理" + oitem.getPath()); } else fileCount += tozipfile.takeWarFileToZip(warlist, oitem); } catch (Exception e) { e.printStackTrace(); } } System.out.println("\n >>> 成功抽取文件数:" + fileCount); // 对zip文件进行检查,对比excel的文件,和zip中的文件 tozipfile.FileInfo(); }
/** 根据起始版本号,获取文件清单;从指定目录 导出到输出目录 */ public void svnDiffToPath() { System.out.println( "===========根据起始版本号svndiff.startversion svndiff.endversion,获取文件清单================="); SVNRepo svnrepo = SVNRepo.getInstance(); List<SvnResource> alist = svnrepo.LogPathList(); // String rootURL = pv.getProperty("svndiff.url"); // rootURL = rootURL.substring(0, // rootURL.lastIndexOf(pv.getProperty("svndiff.keyroot"))); for (SvnResource sr : alist) { String surl = sr.getUrl(); String spath = pv.getProperty("svn.tofolder") + sr.getPath(); try { long v = svnrepo.Export(surl, sr.getVersion(), spath); System.out.println("ver:" + Long.toString(v) + " | " + sr.getPath()); } catch (SVNException e) { // TODO Auto-generated catch block e.printStackTrace(); } // System.out.println(pv.getProperty("svndiff.url")+spath); } System.out.println(">>>变动文件数=" + Integer.toString(alist.size())); System.out.println(" 文件保存在:" + pv.getProperty("svn.tofolder")); // List<SVNDiffStatus> xlist=svnrepo.Diff(); // for(SVNDiffStatus ss:xlist){ // System.out.println(ss.getPath()); // } // System.out.println(">>>===变动文件数=" + Integer.toString(xlist.size())); }
public String svnToPath(FilesList fileslist) { SVNRepo svnrepo = SVNRepo.getInstance(); ToZipFile tozipfile = new ToZipFile(svnrepo); String exportToPath = pv.svntofolder; int fileCount = 0; long lVer = -1; String sMessage = ""; for (FilesListItem oItem : fileslist) { try { // TODO 这里不应该是trunk ??? // String fromPath = oItem.getPath("trunk"); // PathUtils.autoPathRoot(sf.getPath() // aRow.get(ColList_Path), // "trunk"); ExchangePath expath = oItem.getExchange(); String sUrl = expath.getSvnURL(); // expath.getTrunkURL(); // // pv.svnurl + fromPath; // // svn库的文件绝对路径URL String sVer = oItem.getVer(); // aRow.get(ColList_Ver); // String toPath = PathUtils.autoUrlToPath(sUrl, exportToPath, pv.keyRootFolder); // 判断是否目录,目录就不操作 if (PathUtils.isFolder(sUrl)) { System.out.println("目录不处理" + sUrl); } else { if (pv.getProperty("svn.version.verify").equals("true")) { // 必须校验版本号 if (svnrepo.CheckFileVersion(sUrl, sVer)) { svnrepo.Export(oItem); // xclient.svnExport(sUrl, sVer, toPath, // pv.keyRootFolder); System.out.println("export 版本:" + sVer + "|| url=" + sUrl); } else { System.err.println(" -->>>文件版本不存在:[" + sVer + "]" + sUrl); continue; } } else { // 允许不校验版本号 if (StringUtil.isBlank(sVer)) { sMessage = "export Last版本:"; } else if (svnrepo.CheckFileVersion(sUrl, sVer)) { sMessage = "export 版本:"; } else { sMessage = "export Last版本(原" + sVer + "):"; } try { lVer = svnrepo.Export(oItem); // xclient.svnExport(sUrl, sVer, toPath, // pv.keyRootFolder); System.out.println(sMessage + Long.toString(lVer) + "|| url=" + sUrl); } catch (SVNException e) { e.printStackTrace(); System.err.println(" -->>>文件版本不存在:[" + sVer + "]" + sUrl); continue; } } if (pv.getProperty("svn.tozip.enabled").equals("true")) // 将文件添加到zip文件 tozipfile.takeFileToZip(oItem); } fileCount++; } catch (SVNException e) { e.printStackTrace(); } catch (Exception e1) { e1.printStackTrace(); } } System.out.println( "\nTotal " + Integer.toString(fileCount) + " Files, Exported to path =" + PathUtils.addFolderEnd(exportToPath) + pv.svnkeyRoot); tozipfile.FileInfo(); return exportToPath; }