[英]cd command in gradle not working
The cd command in my Gradle task is not working. 我的Gradle任务中的cd命令不起作用。 Using it to go to another folder.
用它来转到另一个文件夹。
task assembleTask(overwrite: true, type:Exec) {
commandLine "gradle", "assembleDev"
doLast {
commandLine "cd tests"
commandLine "ls"
}
}
The Exec
task only runs once. Exec
任务只运行一次。 You are setting the commandLine
property 3 times. 您正在设置
commandLine
属性3次。
If you want one task to run another, you might do 如果您希望一个任务运行另一个任务,您可能会这样做
task assembleTask {
dependsOn assembleDev
doLast {
file('tests').listFiles().each { File f ->
println f.name
}
}
}
Or perhaps you want a GradleBuild task, not sure 或许你想要一个GradleBuild任务,不确定
If you want to run multiple execs in a single task you might want to use project.exec()
instead of Exec
task. 如果要在单个任务中运行多个执行程序,可能需要使用
project.exec()
而不是Exec
任务。 Eg: 例如:
task assembleTask {
doLast {
exec {
commandLine 'foo'
}
exec {
commandLine 'bar'
}
exec {
commandLine 'baz'
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.