|
Table of Contents
- 1. Build Instructions
- 2. For Subclipse (and svnant) Users
- 3. Using JavaSVN with Ant
- 4. Logging JavaSVN operations
1. Build Instructions
1.1. How to build JavaSVN library from sources
Get JavaSVN source code with the svn command line client
$ svn co http://72.9.228.230/svn/jsvn/trunk javasvn
Go to checked out directory
$ cd javasvn
Use ANT to build javasvn.jar
$ ant build-standalone
javasvn/lib
directory will contain built library jar file (javasvn.jar)
and JSCH library (jsch.jar)
that is needed if you are going to use svn+ssh connection
protocol.
1.2. How to build JavaSVN Subclipse Extension plugin from sources
Get JavaSVN source code with the svn command line client
$ svn co http://72.9.228.230/svn/jsvn/trunk javasvn
or (to check out specific version):
$ svn co http://72.9.228.230/svn/jsvn/tags/TAG_NAME javasvn
Go to checked out directory
$ cd javasvn
Set ECLIPSE_HOME environment variable (should point to Eclipse 3.1M6 (or newer) home directory)
$ set ECLIPSE_HOME=/home/user/java/eclipse31M6
Use ANT to build javasvn.jar
$ ant deploy
build/eclipse
directory will contain Eclipse javasvn plugin, feature and update site files.
To make Eclipse use the plugin you've just built, copy all files from
from JAVASVN/build/eclipse/plugins
and JAVASVN/build/eclipse/features
to corresponding Eclipse directories and restart Eclipse:
$ eclipse -clean
Or use "Local Update Site" at JAVASVN/build/eclipse/site
directory to install JavaSVN Subclipse Extension
2. For Subclipse (and svnant) Users
2.1. How to make Subclipse (0.9.30) use JavaSVN library
Though JavaSVN is not yet fully integrated into Subclipse as an extension, you may already try it with Subclipse. Perform the following easy steps to make Subclipse and JavaSVN work together.
With Eclipse Update Manager (tested with Eclipse 3.1M6, WinXP):
- Add http://tmate.org/svn/ as an update site to Eclipse Update Manager.
Use Help | Software Updates | Find and Install in main menu. - Install "JavaSVN Subclipse Extension" feature.
2.2. HTTP proxy setup
Define your proxy port and host in Eclipse Install/Update preferences page.
Additional proxy settings may be defined in ECLIPSE_HOME/configuration/config.ini
file:
user name if proxy needs authentication
http.proxyUser
http.proxyPassword
password if proxy needs authentication
http.nonProxyHosts
, or | delimited host names that should bypass proxy
2.3. SVN+SSH authentication with private key
JavaSVN uses pure java JSCH library to establish SSH connection. This library supports only SSH version 2, with password or private key authentication. Using password authentication is not a problem with Subclipse, but currently it doesn't provide a way to define private key and passphrase for private key authentication. You may use the following properties to let JavaSVN know about your private key and passphrase (you need to provide these properties when starting Eclipse):
$ eclipse -vmargs \ -Djavasvn.ssh2.key=/path/to/private/key/file \ -Djavasvn.ssh2.username=userName \ -Djavasvn.ssh2.passphrase=optionalPassphrase
Note: User name for ssh connection will be taken from SVN Repository properties that may be altered in Subclipse SVN Repositories view.
To avoid special batch script creation to launch Eclipse you may define ssh related properties in
Eclipse config.ini file ECLIPSE_HOME/configuration/config.ini
(tip provided by Andrew Berman):
... javasvn.ssh2.key=path/to/private/key/file javasvn.ssh2.passphrase=passphrase javasvn.ssh2.username=username
In case you work with Mac OS X version of Eclipse it is not too simple to add arguments that make JSCH look for private key file at launch. Instead of command line arguments you can modify Eclipse.app/Contents/Info.plist last array of keys adding something like that (tip provided by Valentin Alekseev):
<array> ... <string>-Djavasvn.ssh2.key=/path/to/key/file</string> </array>
2.4. Making SvnAnt use JavaSVN
Step-by-step instructions:
- Delete existing
javahl.jar
andsvnClientAdapter.jar
(libraries distirbuted with the svnant) from your Ant classpath (ANT_HOME/lib/ directory). - Download latest version of JavaSVN library. You will need javasvn.jar file from the library distribution.
- Get patched version of svnClientAdapter.jar (version 0.9.13).
- Put
javasvn.jar
andsvnClientAdapter-0.9.13.jar
files on your Ant classpath (ANT_HOME/lib/ directory).
After performing the steps above svnant will use JavaSVN instead of JavaHL bindings.
3. Using JavaSVN with Ant
There are two ways of using JavaSVN in Ant tasks. First way is using svnant - part of Subclipce project, you may read JavaSVN+Subclipse documentation page for details. Another way, that is described below, is using JavaSVN command line interface.
3.1. Sample Ant tasks that uses JavaSVN (contributed by William Lovins)
Note: There are areas where this library is very inefficient when working with large repositories which will be resolved in later versions.
Note: The easiest way to use this command is to treat the commands passed to the library the same way that you would the normal svn binary. There is no svn task at this time as there is in the svnant library. This too will be resolved in a later version.
The main advantage to this library is that neither subversion nor any
associated libraries need to be installed on the server.
Additionally, this documentation will be expanded and improved on later
versions. This initial page is being made available for people who
would like to either test this library or who would like to help
improve it (e.g. - writing a proper <svn> task set or
fixing bugs).
3.2. Parameters
Please see the svn documentation for assistance on what parameters the command accepts. A large subset of the command line arguments are available via the javasvn-cli.jar file, including lesser used switches such as "svn status -u".
3.3. Examples
3.1.1. Checking out files from the repositoryIf you need to do an initial checkout, this target will checkout files from http://sources.example.com/TESTING to the local directory /usr/src/TESTREPO. The username and password arguments can be omitted if you have anonymous checkouts from your repository.
<target name="svnCheckout"> <property name="source-root" value="/usr/src"/> <property name="repository.URL" value="http://sources.example.com"/> <java classname="org.tmatesoft.svn.cli.SVN" dir="${source-root}/TESTREPO" fork="true"> <arg value="co"/> <arg value="--username"/> <arg value="admin"/> <arg value="--password"/> <arg value="admin"/> <arg value="${repository.URL}/TESTING"/> <classpath> <pathelement location="${antroot}/LIB/javasvn.jar" /> <pathelement location="${antroot}/LIB/javasvn-cli.jar" /> </classpath> </java> </target>
3.1.2. Commiting files to the repository
If you had an existing local copy of a repository that you want to check files into, you could use the following target to commit the files. The "-m" argument of "Testing" is set differently than the other arguments. Please use a single quote " ' " to surround the double-quoted message, as shown in the example below.
This example would commit all changed files from the local directory
/usr/src/TESTREPO to the repository located at
http://sources.example.com/TESTING the same way that the command line
version would.
<target name="svnCommit"> <property name="source-root" value="/usr/src"/> <property name="repository.URL" value="http://sources.example.com"/> <java classname="org.tmatesoft.svn.cli.SVN" dir="${source-root}/TESTREPO" fork="true"> <arg value="commit"/> <arg value="--username"/> <arg value="admin"/> <arg value="--password"/> <arg value="admin"/> <arg value="-m"/> <arg value='"Testing"'/> <arg value="${repository.URL}/TESTING"/> <classpath> <pathelement location="${antroot}/LIB/javasvn.jar" /> <pathelement location="${antroot}/LIB/javasvn-cli.jar" /> </classpath> </java> </target>
4. Logging JavaSVN operations
If you experience problems that you think are JavaSVN related, it is always a good idea to post a bug report into JavaSVN Issue Tracker. To provide more information with the bug report, please consider attaching JavaSVN log file to it. Below you will find detailed instructions on how to get JavaSVN log file.
4.1. JavaSVN is used as Eclipse plugin (works for Subclipse Extension as well)
When used within Eclipse JavaSVN logs its operation using Eclipse built-in logging facilities. Logging is turned off by default. To enable JavaSVN logging please do the following:
- Copy
ECLIPSE_HOME/plugins/org.tmatesoft.javasvn_version/.options
file toECLIPSE_HOME
directory - Start Eclipse with -debug command line argument:
$eclipse -debug
- In Eclipse, open standard 'Error Log' view - it will contain detailed log of JavaSVN operations that you may export to a file.
Note: OS X users may find it useful to read this article. It describes how to start Eclipse in "-debug" mode.
4.2. JavaSVN is used as library in standalone application
By default JavaSVN uses standard JDK logging API. You may find JavaSVN log file at USER_HOME/.javasvn/.javasvn.0.0.log
Following system properties may be used to control JavaSVN logging output:
javasvn.log.console=true|false [false]
- log to System.out
javasvn.log.file=true|false [true]
- log to file
javasvn.log.path=path/to/log/file
- use specified log file instead of default one
javasvn.log.svn=true|false [false]
- log svn protocol messages
javasvn.log.http=true|false [false]
- log DAV protocol requests
4.3. Setting up your own logger
When you're using JavaSVN in your application it is not always an option to let
JavaSVN use JDK logging API. Instead you may like to have a fine-grained control over
the way JavaSVN logs its operations. The solution is to provide JavaSVN with custom logger
class that should extend DebugLoggerAdapter
class. The code below demonstrates
how it could be done.
.... import org.tmatesoft.svn.util.DebugLog
; import org.tmatesoft.svn.util.DebugLoggerAdapter
; .... public static void initJavaSVNLogger() { DebugLog.setLogger(new CustomJavaSVNLogger()); } private static class CustomJavaSVNLogger extendsDebugLoggerAdapter
{ /* Override superclass methods to redirect logging * as you wish. Superclass implementaion is empty, i.e. * all log messages are swallowed. */ } ....
Note: One have to set up the custom logger before any other calls are made to JavaSVN, otherwise default logging will be used.