示例如下,checkout一个repository到protofile1下面。
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager scm = SVNClientManager.newInstance(options, USER_NAME,
PASSWORD);
SVNUpdateClient client = scm.getUpdateClient();
File protoFile1 = new File(SVN_DIR);
if (protoFile1.exists()) {
// update
} else {
if (!protoFile1.mkdir()) {
System.err.println("holy shit");
return;
}
SVNURL svnUrl = SVNURL.parseURIEncoded(SVN_URL);
client.doCheckout(svnUrl, protoFile1, SVNRevision.HEAD,
SVNRevision.HEAD, SVNDepth.INFINITY, true);
}
SVNClientManager。SVN客户端管理类。svnkit推荐使用这个类来管理所有clinet对象。因为据说效率比较高,比如上面示例中的client就是一个单例。
DefaultSVNOptions/ISVNOption。就是在%APPDATA%/Subversion下面的那个config的抽象。不过考虑到我的那个config文件本身没东西,所以这里也用了默认的。另外,这个接口不是用来设置属性的,根据api,应该是用来在运行时获取server端的config的。
SVNUpdateClient,实际用来checkout or update用的对象。
一些co,ci,up操作还是很简单的~
附上几个网址:
http://svnkit.com/javadoc/index.html
http://wiki.svnkit.com/