Gradle shebang tries to see build.gradle it self as a task

In the top of build.gradle I add a shebang

#!/usr/bin/env gradle

chmod +x build.gradle

Now I run gradle init
./build.gradle init

It fails because it cannot find task called “./build.gradle” …
It would have been nice if it worked … :smile:
what can I do ?

Is there a particular reason you are doing it this way instead of using the gradle wrapper?
Gradle can automatically create a wrapper(runnable script) for you by running gradle wrapper

Hi John
I have actually never used gradle wrapper …
Thanks it works fine…
I just thing shebang is “smart” :slight_smile:

  • and it makes it possible to execute scripts without needing to specify the interpreter
    Some commands can even be executed from “Finder” level.