Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Gradle for Android中获得SVN修订版?_Android_Svn_Gradle_Revision_Gradle Eclipse - Fatal编程技术网

如何在Gradle for Android中获得SVN修订版?

如何在Gradle for Android中获得SVN修订版?,android,svn,gradle,revision,gradle-eclipse,Android,Svn,Gradle,Revision,Gradle Eclipse,我在资源中有字段(svn修订版)。我如何使用Gradle在我的领域中获得svn修订版,而不是通过我的手获得?您可以修改以下解决方案,该解决方案打印出当前的svn修订版 // File: build.gradle task svninfo << { new ByteArrayOutputStream().withStream { os -> def result = exec { executable = 'svn'

我在资源中有字段(svn修订版)。我如何使用Gradle在我的领域中获得svn修订版,而不是通过我的手获得?

您可以修改以下解决方案,该解决方案打印出当前的svn修订版

// 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)
//文件:build.gradle
任务svninfo
def result=exec{
可执行文件='svn'
args=['info']
标准输出=操作系统
}
def outputAsString=os.toString()
def matchLastChangedRev=outputAsString=~/上次更改版本:(\d+)/
println“最新更改版本:${matchLastChangedRev[0][1]}”
}
}
//svn信息的输出示例:
//路径:。
//网址:http://svn.host/svn/project
//存储库根目录:http://svn.host/svn/
//存储库UUID:9de3ae54-a9c2-4644-a1a1-838cb992bc8e
//修订:33
//节点类型:目录
//时间表:正常
//最后更改作者:mrhaki
//最后更改版本:33
//最后更改日期:2010-09-03 14:25:41+0200(2010年9月3日星期五)

您可以修改以下打印当前SVN版本的解决方案

// 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)
//文件:build.gradle
任务svninfo
def result=exec{
可执行文件='svn'
args=['info']
标准输出=操作系统
}
def outputAsString=os.toString()
def matchLastChangedRev=outputAsString=~/上次更改版本:(\d+)/
println“最新更改版本:${matchLastChangedRev[0][1]}”
}
}
//svn信息的输出示例:
//路径:。
//网址:http://svn.host/svn/project
//存储库根目录:http://svn.host/svn/
//存储库UUID:9de3ae54-a9c2-4644-a1a1-838cb992bc8e
//修订:33
//节点类型:目录
//时间表:正常
//最后更改作者:mrhaki
//最后更改版本:33
//最后更改日期:2010-09-03 14:25:41+0200(2010年9月3日星期五)
试试这个

task svnversion {
  description 'Get SVN revision number.'
  new ByteArrayOutputStream().withStream { os ->
    def result = exec {
      executable = 'svnversion'
      standardOutput = os
    }
    ext.revid = os.toString()
  }
}
你可以用它来测试

task printsvn(description: 'Demonstrate calling svnversion task.') {
  println 'Implementation-Build #' + svnversion.revid
}
结果

$gradle printsvn
:printsvn
实施构建#3071

成功构建

总时间:0.776秒

task svnversion {
  description 'Get SVN revision number.'
  new ByteArrayOutputStream().withStream { os ->
    def result = exec {
      executable = 'svnversion'
      standardOutput = os
    }
    ext.revid = os.toString()
  }
}
你可以用它来测试

task printsvn(description: 'Demonstrate calling svnversion task.') {
  println 'Implementation-Build #' + svnversion.revid
}
结果

$gradle printsvn
:printsvn
实施构建#3071

成功构建


总时间:0.776秒

我的答案有帮助吗?我的答案有帮助吗?