grails将svn修订版添加到app.version

grails将svn修订版添加到app.version,svn,grails,groovy,build,Svn,Grails,Groovy,Build,我正在尝试将svn修订版添加到我的app.version,而不需要ant或其他类似的外部工具。看起来我可能能够连接到\u Events.groovy,但文档相对较少 有人知道如何做到这一点吗?来自Grails nabble邮件列表的链接提供了您正在寻找的解决方案。为了完整起见,请将代码放在此处: 在scripts/\u Events.groovy中 eventWarStart = { type -> println "******************* eventWarSt

我正在尝试将svn修订版添加到我的
app.version
,而不需要ant或其他类似的外部工具。看起来我可能能够连接到
\u Events.groovy
,但文档相对较少

有人知道如何做到这一点吗?

来自Grails nabble邮件列表的链接提供了您正在寻找的解决方案。为了完整起见,请将代码放在此处:

scripts/\u Events.groovy中

eventWarStart = { type -> 

    println "******************* eventWarStart *****************" 
    try { 
        // initialise SVNKit 
        DAVRepositoryFactory.setup(); 
        SVNRepositoryFactoryImpl.setup(); 
        FSRepositoryFactory.setup(); 

        SVNClientManager clientManager = SVNClientManager.newInstance(); 
        println "clientManager = " + clientManager.toString(); 
        SVNWCClient wcClient = clientManager.getWCClient(); 
        println "wcClient = " + wcClient.toString(); 

        // the svnkit equivalent of "svn info" 
        File baseFile = new File(basedir); 

        println "baseFile = " + baseFile.toString(); 
        SVNInfo svninfo = wcClient.doInfo(baseFile, SVNRevision.WORKING); 
        println "svninfo = " + svninfo.toString(); 

        def version = svninfo.getURL(); 
        println "Setting Version to: ${version}" 
        metadata.'app.version' = "${version}".toString() 
        metadata.persist() 

    } 
    catch (SVNException ex) { 
        //something went wrong 
        println "**************** SVN exception **************" 
        println ex.getMessage(); 
    } 

} // End eventWarStart() 

Grails 3.x,在build.gradle中,将svn修订版添加到应用程序版本:

version "1.0.${getSvnRevision()}"

def getSvnRevision() {
    def proc = "svnversion".execute()
    return proc.in.text
}

这非常有效,除了在git svn后面。我必须退出我的构建服务器才能获得应用程序版本,但这是一条路。这将打印SVN url,而不是建议的版本。我想要版本号,所以我使用了
def version=svninfo.revision