我想使用javahl从java程序中签出来自svn的源代码。尝试使用Javahl,因为它似乎是免费的,也可用于商业用途。
我需要将http://example.com/svn/project1/trunk之类的内容签出到本地目录。
这应该是一个相当简单的过程,只需要几行代码?我仍然找不到任何关于如何做到这一点的教程。
你能给出一些java行的例子吗?
发布于 2018-09-27 04:39:18
我知道这个问题有点老生常谈了,但今天我不得不做一些类似的事情。我也找不到任何好的教程,最终使用unit tests作为我的参考。
下面是一些适用于我的Java代码:
import org.apache.subversion.javahl.ClientException;
import org.apache.subversion.javahl.SVNClient;
import org.apache.subversion.javahl.types.Depth;
import org.apache.subversion.javahl.types.Revision;
...
static void checkout(String reproUrl, String workingDirectory) throws ClientException {
SVNClient client = new SVNClient();
client.checkout(
reproUrl,
workingDirectory,
Revision.HEAD,
Revision.HEAD,
Depth.infinity,
false,
false);
}
如果您需要进行身份验证,SVNClient
提供了username(String)
和password(String)
方法。
发布于 2011-07-07 17:27:35
查看http://wiki.svnkit.com/Getting_Started_With_SVNKit和http://wiki.svnkit.com/Managing_A_Working_Copy
private static long checkout( SVNURL url , SVNRevision revision , File destPath , boolean isRecursive ) throws SVNException {
SVNUpdateClient updateClient = ourClientManager.getUpdateClient( );
/*
* sets externals not to be ignored during the checkout
*/
updateClient.setIgnoreExternals( false );
/*
* returns the number of the revision at which the working copy is
*/
return updateClient.doCheckout( url , destPath , revision , revision , isRecursive );
}
https://stackoverflow.com/questions/6608387
复制相似问题