迭代执行任务

时间:2014-12-24 21:10:40

标签: android groovy gradle

在下面提供的代码中,我可以打印目录中的每个文件名,但是当它到达Exec命令时,它只对最后一个文件执行Exec。

task frmf2xml(type:Exec)  {
    new File('src/orca/').eachFile {file ->
        if(file.name.endsWith(".fmb")){
            println file
            commandLine 'cmd', '/c', 'frmf2xml.bat', file, 'OVERWRITE=YES'
        }
   }
}

我希望它能在每个文件上运行该工具

1 个答案:

答案 0 :(得分:0)

实际上我找到了一个解决方案,使用execute()

task frmf2xml()  {
    new File('src/orca/').eachFile {file ->
        if(file.name.endsWith(".fmb")){                
            def cmd = "cmd /c frmf2xml.bat ${file} OVERWRITE=YES"
            def result = cmd.execute();
            result.waitFor();
        }
   }
}
相关问题