Using svnkit to operate Svn in Java

Source: Internet
Author: User

Svnkit is a fully Java-based subversion open-source tool library. Through the APIS provided by svnkit, you can use Java to operate SVN, suchCodeSubmit, update, and so on. The following example shows how to use svnkit to obtain the latest version of the svn repository.

Introduce the jar package svnkit. jar. The test code is as follows:

@ Test

Public void testsvnheaderversion () throws svnexception {

/*

* Initialize the version library. When using https or http to access SVN, run davrepositoryfactory. Setup ();

* Run svnrepositoryfactoryimpl. Setup () to access SVN through SVN: // and SVN + XXX ();

* For SVN access through file: //, execute fsrepositoryfactory. Setup ();

*/

Svnurl url = svnurl. parseuriencoded ("https://svn.xxx.com/xx/xxxx/xxx/trunk/xxx/xxx/"); // obtain the URL of a directory in SVN. That is, the URL address corresponding to the version Library

Davrepositoryfactory. Setup (); // Initialization

Isvnoptions Options = svnwcutil. createdefaultoptions (true); // driver options

Isvnauthenticationmanager authmanager = svnwcutil. createdefaauthauthenticationmanager ("username", "password"); // provides authentication

Svnrepository repos = svnrepositoryfactory. Create (URL );

Repos. setauthenticationmanager (authmanager); // sets Authentication

Logger. debug (">>>" + repos. getlocation (); // print the current version LIBRARY PATH

Logger. debug (">>>" + repos. getlatestrevision (); // obtain the latest version of the current version Library

}

The execution result is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.