Skip to content

Instantly share code, notes, and snippets.

@aliencode
Created July 5, 2013 07:39
Show Gist options
  • Save aliencode/5932715 to your computer and use it in GitHub Desktop.
Save aliencode/5932715 to your computer and use it in GitHub Desktop.
Gradle - 解析Exec的输出结果 Exec DSL调用方法
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]}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment