Grails的SVN版本添加到app.version [英] grails add svn revision to app.version

查看:147
本文介绍了Grails的SVN版本添加到app.version的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在SVN版本添加到我的 app.version 无需蚂蚁或其他一些类似的外部工具。它看起来像我也许可以挂接到 _Events.groovy 来此,但文档相对稀疏。

I'm trying to add the svn revision to my app.version without requiring ant or some other similar external tool. It looks like I might be able to hook into _Events.groovy to this, but the documentation is relatively sparse.

任何人都知道如何做到这一点?

Anyone know how to do this?

推荐答案

从Grails的nabble邮件列表的链接有你要找的解决方案。也把code是为了完整性:

This link from the Grails nabble mailing list has the solution you're looking for. Also putting the code here for completeness:

脚本/ _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的SVN版本添加到app.version的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆