Currently, an Exec task will throw an exception if it can’t find the executable it’s trying to run. This happens even if ignoreExitValue == true
. Is there a way to prevent this? What’s the recommended way to try to execute a console command and continue even if it fails?
You could do:
someExecTask(type: Exec) {
onlyIf { /* executable exists */ }
}
Thank you for the suggestion! I’m not sure it solves the problem I’m having. I think I didn’t describe what I’m trying to do properly.
I want to run an external program, which runs some setup tasks. These tasks are not necessary for a functional build, but if they’re completed they enable some additional functionality. Some systems don’t have this software installed, so I want them to cleanly continue with the build. If I set it to run onlyIf
how can I specify other tasks which should run after this step? I have tasks which dependOn
this one, won’t using onlyIf
abort execution? I don’t see a clean way to specify "run this task, if it fails, continue with the rest of the build`
I suspect I am missing something simple.
No, it just doesn’t execute that task. You’ll have to do a similar thing all the way down the line.