The cd command in my Gradle task is not working. 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. You are setting the commandLine
property 3 times.
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
If you want to run multiple execs in a single task you might want to use project.exec()
instead of Exec
task. Eg:
task assembleTask {
doLast {
exec {
commandLine 'foo'
}
exec {
commandLine 'bar'
}
exec {
commandLine 'baz'
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.