I am using Gradle for AOSP, I would like to check if a command exists in my build environment.
task printCommand{
    doLast{
        def command = "git --version"
        println command.execute().text
    }
}
Above code run perfect, it will print the output from command "git --version".
But I try another command according to Check if a program exists from a Bash script
task printCommand{
    doLast{
        def command = "command -v docker"
        println command.execute().text
    }
}
It always show the wrong message like this.
Execution failed for task ':printCommand'. java.io.IOException: Cannot run program "command": error=2, No such file or directory
Why I can't use "command -v docker" in this way ?
Are there any better ways to check if a command exists in Gradle ?
 
    