Last active
October 21, 2020 21:51
-
-
Save thombergs/9279728 to your computer and use it in GitHub Desktop.
Accessing the SVN revision number in a Gradle script
This file contains hidden or 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
Good tip, thanks.
You should change svnkit version to recent '1.8.11' to avoid 'Client is too old' exception.