如何在Gradle for Android中获得SVN修订版? [英] How to get SVN revision in Gradle for Android?

查看:246
本文介绍了如何在Gradle for Android中获得SVN修订版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在资源中有field(svn revision)。如何在Gradle中使用我的字段中的svn修订版,而不是通过我的手来完成这项工作? 您可以修改以下解决方案,此处解释,它打印出当前的SVN版本。

  //文件:build.gradle 
任务svninfo<< ; {
new ByteArrayOutputStream()。withStream {os - >
def result = exec {
executable ='svn'
args = ['info']
standardOutput = os
}
def outputAsString = os。 toString()
def matchLastChangedRev = outputAsString =〜/ Last Lastd Rev:(\d +)/
println最新更改版本#:$ {matchLastChangedRev [0] [1]}
}
}

// svn info输出示例:
//路径:。
// URL:http://svn.host/svn/project
//存储库根目录:http://svn.host/svn/
//存储库UUID:9de3ae54-a9c2 -4644-a1a1-838cb992bc8e
//修正版本:33
//节点类型:目录
//计划:正常
//最后更改作者:mrhaki
/ / Last Changed Rev:33
//最后修改日期:2010-09-03 14:25:41 +0200(星期五,2010年9月3日)


I have field (svn revision) in resource. How can I get svn revision in my field using by Gradle, that not to do that by my hands?

解决方案

You could modify the following solution, explained here, which prints out the current SVN revision.

// File: build.gradle
task svninfo << {
    new ByteArrayOutputStream().withStream { os ->
        def result = exec {
            executable = 'svn'
            args = ['info']
            standardOutput = os
        }
        def outputAsString = os.toString()
        def matchLastChangedRev = outputAsString =~ /Last Changed Rev: (\d+)/
        println "Latest Changed Revision #: ${matchLastChangedRev[0][1]}"
    }
}

// Example output for svn info:
// Path: .
// URL: http://svn.host/svn/project
// Repository Root: http://svn.host/svn/
// Repository UUID: 9de3ae54-a9c2-4644-a1a1-838cb992bc8e
// Revision: 33
// Node Kind: directory
// Schedule: normal
// Last Changed Author: mrhaki
// Last Changed Rev: 33
// Last Changed Date: 2010-09-03 14:25:41 +0200 (Fri, 03 Sep 2010)

这篇关于如何在Gradle for Android中获得SVN修订版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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