scm4j/scm4j-vcs-svn


Lightweight Java SVN library

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.ProjectKaiser:pk-vcs-svn:16.0'
	}
	dependencies {
		implementation("com.github.ProjectKaiser:pk-vcs-svn:16.0")
	}
	<dependency>
	    <groupId>com.github.ProjectKaiser</groupId>
	    <artifactId>pk-vcs-svn</artifactId>
	    <version>16.0</version>
	</dependency>

                            
    libraryDependencies += "com.github.ProjectKaiser" % "pk-vcs-svn" % "16.0"
        
        

                            
    :dependencies [[com.github.ProjectKaiser/pk-vcs-svn "16.0"]]
        
        

Readme


Release Build Status Coverage Status

Overview

scm4j-vcs-svn is lightweight library for execute basic SVN VCS operations (merge, branch create etc). It uses scm4j-vcs-api exposing IVCS implementation for SVN repositories and SVNKit as framework to work with SVN repositories. Features:

  • Branch create and remove
  • Branch merge returning result(success or list of conflicted files)
  • Commit messages list
  • Summarized diff between branches
  • Branches list
  • File content getting and setting
  • File create and remove

Use cases

  • VCS server hooks
  • Build machines
    • checking in\out, tagging
  • Software project management systems
    • Create own branches from GUI, browse commits, product versions management, etc
  • Product release automation
    • automatic merging, forking, tagging, version bumping, etc
    • Example: scm4j-releaser

Terms

  • Workspace Home
    • Local home folder of all folders used by vcs-related operations. See scm4j-vcs-api for details
  • Locked Working Copy, LWC
    • Local folder where vcs-related operations are executed. Provides thread- and process-safe repository of working folders. See scm4j-vcs-api for details
  • Test Repository
    • A local file-based SVN repository used for functional testing
    • Creates new before and deletes after each test automatically
    • Named randomly (uuid is used)

Using scm4j-vcs-svn

  • Add github-hosted scm4j-vcs-svn project as maven dependency using jitpack.io. As an example, add following to gradle.build file:

    	allprojects {
    		repositories {
    			maven { url "https://jitpack.io" }
    		}
    	}
    
    	dependencies {
    		// versioning: master-SNAPSHOT (lastest build, unstable), + (lastest release, stable) or certain version (e.g. 1.1)
    		compile 'com.github.scm4j:scm4j-vcs-svn:+'
    	}
    

    Or download release jars from https://github.com/scm4j/scm4j-vcs-svn/releases

  • Code snippet

    	public static final String WORKSPACE_DIR = System.getProperty("java.io.tmpdir") + "svn-workspaces";
    	IVCSWorkspace workspace = new VCSWorkspace(WORKSPACE_DIR);
    	String repoUrl = "https://github.com/MyUser/MyRepo";
    	IVCSRepositoryWorkspace repoWorkspace = workspace.getVCSRepositoryWorkspace(repoUrl);
    	IVCS vcs = new SVNVCS(repoWorkspace, "username", "pass");
    
  • Use methods of IVCS interface. See scm4j-vcs-api for details
  • Use vcs.setProxy() and vcs.setCredentials() if necessary

Implementation details

  • SVNKit is used for manage SVN repositories
  • LWC is obtained automatically when necessary

Functional testing

  • To execute tests just run SVNVCSTest class as JUnit test. Tests from VCSAbstractTest class will be executed. See scm4j-vcs-test for details
  • Or run gradle test

Limitations

  • According to IVCS description IVCS.getBranches() should return list of user-created branches. But a branch and a dir are the same for SVN. So SVNVCS.getBranches() returns set of first-level folders of "Branches/" branch and "Trunk" branch. I.e.:
    • Assume we have following directory structure:
      • Branches/Br1/Folder/file.txt
      • Branches/Br2/Folder/file.txt
      • Trunk/Folder/file.txt
      • Tags/Tag1/
    • Then SVNVCS.getBranches() method will return [Br1, Br2, Trunk]