1. project/build.gradle
classpath 'org.tmatesoft.svnkit:svnkit:1.9.3' // 添加该库
2. 使用
/**
* 获取svn版本号
*/
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.getCommittedRevision()
return revision.getNumber()
}
网友评论