What is the difference between using gradlew
and gradle
or are they the same?
2 Answers
The difference lies in the fact that ./gradlew
indicates you are using a gradle wrapper. The wrapper is generally part of a project and it facilitates installation of gradle. If you were using gradle without the wrapper you would have to manually install it - for example, on a mac brew install gradle
and then invoke gradle using the gradle
command. In both cases you are using gradle, but the former is more convenient and ensures version consistency across different machines.
Each Wrapper is tied to a specific version of Gradle, so when you first run one of the commands above for a given Gradle version, it will download the corresponding Gradle distribution and use it to execute the build.
Not only does this mean that you don’t have to manually install Gradle yourself, but you are also sure to use the version of Gradle that the build is designed for. This makes your historical builds more reliable
Read more here - https://docs.gradle.org/current/userguide/gradle_wrapper.html
Also, Udacity has a neat, high level video explaining the concept of the gradle wrapper - https://www.youtube.com/watch?v=1aA949H-shk

- 4,853
- 3
- 30
- 33
-
11Maybe I'm reading it wrong but sounds like a red flag to me. It sounds like Gradle is not backward compatible, or it's evolving very fast (and unstable). What happens with CI servers that do not have access to the internet? – The Impaler Feb 15 '19 at 15:11
-
@TheImpaler I guess you have to install all the required versions of Gradle as the Wrapper would if it had Internet access. – Ruslan Nov 28 '19 at 18:28
-
so a one-liner conclusion might be: always prefer `./gradlew build` over `gradle build` right? – OrenIshShalom Mar 29 '21 at 09:13
-
@OrenIshShalom correct, you don't even have to specify the build part as `clean` and `build` is the Default tasks, when you execute `./gradlew` – Vivek Shukla May 16 '21 at 22:53
gradle vs gradlew
gradlew
is a wrapper(w - character) that uses gradle
.
Under the hood gradlew
performs three main things:
- Download and install the correct
gradle
version - Parse the arguments
- Call a
gradle
task
Using Gradle Wrapper we can distribute/share a project to everybody to use the same version and Gradle's functionality(compile, build, install...) even if it has not been installed.
To create a wrapper run:
gradle wrapper
This command generate:

gradle-wrapper.properties
will contain the information about the Gradle distribution
*./
Is used on Unix to specify the current directory

- 29,217
- 8
- 193
- 205