在下面提供的代码中,我可以打印目录中的每个文件名,但是当到达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'
}
}
}
我希望它在每个文件上运行该工具
最佳答案
实际上,我使用 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();
}
}
}
关于android - 迭代执行任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27642207/