-
-
Save jhyry-gcpud/cb1f4e6f41d37a55a54cce82ba32eb9d to your computer and use it in GitHub Desktop.
Accessing the SVN revision number in a Gradle script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.tmatesoft.svn.core.wc.* | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7.11' | |
} | |
} | |
def getSvnRevision(){ | |
ISVNOptions options = SVNWCUtil.createDefaultOptions(true); | |
SVNClientManager clientManager = SVNClientManager.newInstance(options); | |
SVNStatusClient statusClient = clientManager.getStatusClient(); | |
SVNStatus status = statusClient.doStatus(projectDir, false); | |
SVNRevision revision = status.getRevision(); | |
return revision.getNumber(); | |
} | |
allprojects { | |
version = '1.2.3.' + getSvnRevision() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment