java 的svn客户端调
pom依赖
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.3.5</version>
</dependency>
java调用代码
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNLogClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
public class SvnTest {
static {
DAVRepositoryFactory.setup();}
private SVNClientManager manager;
private SVNURL repositoryBaseUrl;
public SvnTest() {
DefaultSVNOptions options = new DefaultSVNOptions();
manager = SVNClientManager.newInstance(options);
try {
repositoryBaseUrl = SVNURL.parseURIDecoded("http://svn.apache.org/repos/asf/logging/log4j/trunk/src/main/java/org/apache/log4j/or");
} catch (SVNException e) {
e.printStackTrace();}}
public void test() throws SVNException {
SVNLogClient logClient = manager.getLogClient();
DirEntryHandler handler = new DirEntryHandler(); // 在sv
logClient.doList(repositoryBaseUrl, SVNRevision.HEAD, SVNRevision.HEAD,false, true, handler);
UpdateEventHandler svnEventHandler = new UpdateEventHandler();
SVNUpdateClient client = manager.getUpdateClient();
client.setIgnoreExternals(true);
client.setEventHandler(svnEventHandler);
File to = new File("e:\\log\\testsvn");
client.doCheckout(repositoryBaseUrl, to, SVNRevision.HEAD,SVNRevision.HEAD, SVNDepth.INFINITY, false);
client.setIgnoreExternals(true);
client.setEventHandler(svnEventHandler);
lient.doUpdate(to, SVNRevision.HEAD, SVNDepth.INFINITY,true, false);}
public static void main(String[] args) throws SVNException {
SvnTest svntest = new SvnTest();
svntest.test();}