我已经阅读了 stackoverflow 和 gradle 表单,但我仍然感到困惑。这里的最终目标是,在我复制一些文件后,我想设置可写标志——因为“复制”不喜欢覆盖“nix”上的只读文件(呵呵...),也不能强迫它这样做这样做(哼!)。
这是我所拥有的概要:
task setPermissions (type : Exec) {
executable = 'chmod -R +w'
}
// ... a little while later ...
task('somethingElse') << {
// ... unrelated stuff ...
def String targetDir = "$aVar/theTarget"
// >> TASK CALL <<
setPermissions {
commandLine = [executable + " $targetDir"]
}
// but that doesn't work... this does...
proc = Runtime.getRuntime().exec("chmod -R +w $deployDir")
proc.waitFor()
}
我尝试过“setPermissions”的变体。
Trial 1:
commandLine = 'chmod'
args = '-R', '+w'
在这种情况下,当我调用 setPermissions 时,我将目标目录附加到“args”。
Trial 2:
commandLine = 'chmod -R +w'
在这种情况下,当我调用 setPermissions 时,我将目标目录附加到“命令行”。我还尝试将其设为唯一的“args”值。
Trial 3:
commandLine = 'chmod', '-R', '+w'
在这种情况下,当我调用 setPermissions 时,我将目标目录附加到“命令行”。我还尝试将其设为唯一的“args”值。
那么我在这里做错了什么,Exec 任务无法正常运行,但 Rt.gR.exec() 可以?