Return to Snippet

Revision: 63023
at April 1, 2013 02:33 by laurenceosx


Updated Code
/*
	File  : helperSvn.gradle
	Author: Laurence Toenjes
	Date  : 3/31/2013
	
	Example of how to use:
		1. Put this file in the same directory as your build.gradle file.
		
		2. Near the very top of your build.gradle source file add this line: 
			apply from: 'helperSvn.gradle'
			
		3. You can now do svn commands like:
		
			doSvnMain( 'export', 'http://svn.codehaus.org/gmod/gsql/tags/gsql-1.5.0/', 'build/svnExport' );
			
			doSvnMain( 'help' );
			
			... etc. ...
			
			Note: each command line arg you would normally supply to a svn command should be an arg passed to doSvnMain
				  (since we are not using the OS shell you should probably not have to double quote any of the args).
*/

import org.tmatesoft.svn.cli.SVN;

buildscript {
	repositories { mavenCentral() }
	dependencies { classpath( 'org.tmatesoft.svnkit:svnkit:1.7.8', 'org.tmatesoft.svnkit:svnkit-cli:1.7.8' ) }
}

project.ext.SVN = SVN; /* for certain scenarios might be useful to share this project var */

def _disableSystemExitCall = {
	System.setSecurityManager(
		new SecurityManager() {
			@Override public void checkPermission(java.security.Permission perm) {}
			@Override public void checkExit(int status) { throw new SecurityException(); }
		}	
	);
};

def _enableSystemExitCall = { System.setSecurityManager(null); };

/* for certain scenarios might be useful to share these closures with build */
project.ext.disableSystemExitCall = _disableSystemExitCall;
project.ext.enableSystemExitCall  = _enableSystemExitCall;

/* key method/closure - used as: doSvnMain( 'your', 'svn', 'args', 'go', 'here' ); */
project.ext.doSvnMain = { String... aSvnArgs ->
	_disableSystemExitCall(); /* stop SVN.main from doing a System.exit call */
	try {
		SVN.main( aSvnArgs as String[] );
	} finally {
		_enableSystemExitCall();
	}
} ;

Revision: 63022
at April 1, 2013 02:32 by laurenceosx


Initial Code
/*
	File  : helperSvn.gradle
	Author: Laurence Toenjes
	Date  : 3/31/2013
	
	Example of how to use:
		1. Put this file in the same directory as your build.gradle file.
		
		2. Near the very top of your build.gradle source file add this line: 
			apply from: 'helperSvn.gradle'
			
		3. You can now do svn commands like:
		
			doSvnMain( 'export', 'http://svn.codehaus.org/gmod/gsql/tags/gsql-1.5.0/', 'build/svnExport' );
			
			doSvnMain( 'help' )
			
			... etc. ...
			
			Note: each command line arg you would normally supply to a svn command should be an arg passed to doSvnMain
				  (since we are not using the OS shell you should probably not have to double quote any of the args).
*/

import org.tmatesoft.svn.cli.SVN;

buildscript {
	repositories { mavenCentral() }
	dependencies { classpath( 'org.tmatesoft.svnkit:svnkit:1.7.8', 'org.tmatesoft.svnkit:svnkit-cli:1.7.8' ) }
}

project.ext.SVN = SVN; /* for certain scenarios might be useful to share this project var */

def _disableSystemExitCall = {
	System.setSecurityManager(
		new SecurityManager() {
			@Override public void checkPermission(java.security.Permission perm) {}
			@Override public void checkExit(int status) { throw new SecurityException(); }
		}	
	);
};

def _enableSystemExitCall = { System.setSecurityManager(null); };

/* for certain scenarios might be useful to share these closures with build */
project.ext.disableSystemExitCall = _disableSystemExitCall;
project.ext.enableSystemExitCall  = _enableSystemExitCall;

/* key method/closure - used as: doSvnMain( 'your', 'svn', 'args', 'go', 'here' ); */
project.ext.doSvnMain = { String... aSvnArgs ->
	_disableSystemExitCall(); /* stop SVN.main from doing a System.exit call */
	try {
		SVN.main( aSvnArgs as String[] );
	} finally {
		_enableSystemExitCall();
	}
} ;

Initial URL


Initial Description
Sample SVN call from gradle: doSvnMain( 'your', 'svn', 'args', 'go', 'here' );

Initial Title
Groovy Gradle - Do SVN Commands without having SVN installed.

Initial Tags
groovy

Initial Language
Groovy