Armand
Armand

Reputation: 24343

How to tell gradle to use the wrapper if it's present?

Is there a global configuration option for gradle so that it will use the gradle wrapper if gradlew is present?

Upvotes: 1

Views: 227

Answers (2)

Sten Roger Sandvik
Sten Roger Sandvik

Reputation: 2536

You could install and use gdub (https://github.com/dougborg/gdub). This will use the gradle wrapper if found for the project, or use globally installed gradle if not found.

Installing it was literally just two lines of code:

$ curl -sLo- http://get.bpkg.sh | bash
$ bpkg install dougborg/gdub -g

And use it like this:

$ gw build

Upvotes: 0

Armand
Armand

Reputation: 24343

Add the following to ~/.bashrc or ~/.bash_profile file:

gradle() {
        if [ -f ./gradlew ]; then
                ./gradlew "$@"
        else
                command gradle "$@"
        fi
}

Upvotes: 2

Related Questions