groovy

替换:
    def replace = { file, s1, s2 ->
        def text = file.text.replaceAll(s1, s2)
        file.withPrintWriter{ printWriter ->
            printWriter.println(text)
        }
    }
    def dir = new File("groovyTest/1/AndroidManifest.xml")
    replace(dir, 'versionCode=\"[0-9]*\"', 'versionCode=\"11211\"')


运行终端命令:
    def proc = "sh sh_test.sh".execute()
    println proc.text

在指定目录下执行命令
def f = new File("1")
def command = "groovy groovyTest.groovy"
def proc = command.execute(null, f)
proc.waitFor()
print proc.text

你可能感兴趣的:(groovy)