SvnKit
地址:https://svnkit.com/download.php
项目需要做了个简单的demo,可以进行基础操作。demo可以运行,但是更多高级更多实现需要自己在扩展。因为这个项目已经进入Thread.sleep :( ,开展新项目了 :(
功能
1.实现了几个基础操作
2.提供了日志操作
项目结构
首先我们先创建3个对象来为后面服务
package com.svn.model;
/**
* Svn账号信息
*
* @author Allen
* @date 2016年8月8日
*/
public class SvnAccountPojo implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String svnAccount;// svn账号
private String svnPassword;// svn密码
protected SvnAccountPojo() {
// TODO Auto-generated constructor stub
}
public SvnAccountPojo(String svnAccount, String svnPassword) {
super();
this.svnAccount = svnAccount;
this.svnPassword = svnPassword;
}
public String getSvnAccount() {
return svnAccount;
}
public void setSvnAccount(String svnAccount) {
this.svnAccount = svnAccount;
}
public String getSvnPassword() {
return svnPassword;
}
public void setSvnPassword(String svnPassword) {
this.svnPassword = svnPassword;
}
}
package com.svn.model;
/**
* Svn链接状态信息
*
* @author Allen
* @date 2016年8月8日
*/
public class SvnLinkPojo extends SvnAccountPojo {
/**
*
*/
private static final long serialVersionUID = 1L;
private String repoPath;// 库链接路径
public SvnLinkPojo(String repoPath, String svnAccount, String svnPassword) {
super(svnAccount, svnPassword);
this.repoPath = repoPath;
}
public SvnLinkPojo(String svnAccount, String svnPassword) {
super(svnAccount, svnPassword);
}
public String getRepoPath() {
return repoPath;
}
public void setRepoPath(String repoPath) {
this.repoPath = repoPath;
}
}
package com.svn.model;
import java.util.Date;
/**
* SVN资源库对象
*
* @author Allen
* @date 2016年8月8日
*/
public class SvnRepoPojo implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String commitMessage; // 提交信息
private Date date; // 提交日期
private String kind; // 提交方式 dir目录 file文件 none空 unknown 未知
private String name;// 目录名
private String repositoryRoot; // 资源库路径
private long revision; // 提交的svn版本号
private long size; // 提交的文件数
private String url; // 更变的目录地址
private String author;// 作者
private String state;// 状态
public String getCommitMessage() {
return commitMessage;
}
public void setCommitMessage(String commitMessage) {
this.commitMessage = commitMessage;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRepositoryRoot() {
return repositoryRoot;
}
public void setRepositoryRoot(String repositoryRoot) {
this.repositoryRoot = repositoryRoot;
}
public long getRevision() {
return revision;
}
public void setRevision(long revision) {
this.revision = revision;
}
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
创建svn基础服务接口
package com.svn.inf.service;
/**
* svn主服务创建
*
* @author Allen
* @date 2016年8月8日
*/
public interface ISvnService {
/**
* 创建SNV版本库服务
*
* @author Allen
* @date 2016年8月11日
*/
public void createSVNRepository();
/**
* 关闭版本库容器,便于刷新重连等
*
* @author Allen
* @date 2016年8月11日
*/
public void closeRepo();
/**
* 创建svn客户操作服务
*
* @author Allen
* @date 2016年8月11日
*/
public void createSVNClientManager();
}
建立主功能接口
package com.svn.inf;
import java.io.File;
import java.util.List;
import com.svn.inf.service.ISvnDbLog;
import com.svn.inf.service.ISvnService;
import com.svn.model.SvnRepoPojo;
/**
* svn操作大全
*
* @author Allen
* @date 2016年8月8日
*/
public interface ISvn extends ISvnService {
/**
* 获取目标路径下版本库数据信息
*
* @param openPath
* 需要查看的版本库路径
* @return 版本库列表 {@link SvnRepoPojo}
* @author Allen
* @date 2016年8月11日
*/
public List<SvnRepoPojo> getRepoCatalog(String openPath);
/**
* 检出到目录
*
* @param checkUrl
* 检出目标URL
* @param savePath
* 检出到本地路径
* @return true|false
* @author Allen
* @date 2016年8月11日
*/
public boolean checkOut(String checkUrl, String savePath);
/**
* 添加到版本库
*
* @see 先添加文件夹再添加文件
* @param paths
* 提交文件路径
* @param message
* 提交信息
* @param uLocks
* 是否解锁
* @param isvnLog
* 数据持久化接口 {@link ISvnDbLog}
* @return trun|false
* @author Allen
* @date 2016年8月11日
*/
public <T> boolean add(String[] paths, String message, boolean uLocks, ISvnDbLog<? extends T> isvnLog);
/**
* 提交到版本库(所有写操作已在内部调用过COMMIT,自行调用则需要手动同步到DbLog)
*
* @param files
* 提交的文件路径
* @param message
* 提交信息
* @param uLocks
* 是否解锁
* @return 返回提交后版本号-1为提交失败
* @author Allen
* @date 2016年8月11日
*/
public Long commit(File[] files, String message, boolean uLocks);
/**
* 删除到版本库
*
* @see 先删除文件再删除文件夹
* @param paths
* 提交文件路径
* @param localDelete
* <ul>
* <li>如果是true则在本地也删除此文件,false则只删除版本库中的此文件</li>
* <li>删除实体文件时要注意</li>
* <li>删除文件夹时其目录下所有内容都要提交到<b>参数paths</b>中,否则无法删除实体文件</li>
* </ul>
* @param message
* 提交内容解释
* @param uLock
* 是否解锁
* @param isvnLog
* 数据持久化接口 {@link ISvnDbLog}
* @return true|false
* @author Allen
* @date 2016年8月11日
*/
public <T> boolean delete(String[] paths, boolean localDelete, String message, boolean uLock, ISvnDbLog<? extends T> isvnLog);
/**
* 更新到版本库
*
* @param path
* 要更新的文件目录
* @param message
* 提交内容解释
* @param uLock
* 是否解锁
* @param isvnLog
* 数据持久化接口 {@link ISvnDbLog}
* @return true|false
* @author Allen
* @date 2016年8月11日
*/
public <T> boolean update(String path, String message, boolean uLock, ISvnDbLog<? super T> isvnLog);
/**
* 比对目录下内容信息
*
* @see 返回delete,update文件列表
* @param file
* 待比对的目标文件路径
* @return 返回有差异的文件路径否则为null
* @author Allen
* @date</