Why Gradle wrapper?:
Developer's working on Gradle project uses Gradle Wrapper because it takes care of managing Gradle version on which the project is build upon. So when we ship it to others, they need not to install any setup environments for the project to run. There are some files which needs to be present inorder to run in desired build-way by developer.
Gradle wrapper ensures our build will always run with same Gradle version irrespective of who is executing the build and if Gradle is installed or not as long as one is using Graddle Wrapper to build the project. In short
"Design our own build for the Gradle version and be sure it will not fail irrespective of gradle versione used by other developer".
Gradle doesn't execute the tasks rather it ensure that project has the desired Gradle distribution and then invoke it for respective execution demanded to be carried out. What happens is, it ignores already installed Gradle version. When Gradle wrapper is invoked it first checks in
~/.gradle/ to find if desired version is present. If it fails to find, it downloads automatically.
Open the project directory run -
using gradlew, task can be executed for the project
Gradle files in project directory:
gradlew: It's a Shell script for unix user to execute gradle tasks.
gradle.bat: bat script for windows user to execute gradle tasks
gradle/wrapper/gradle-wrapper.jar: Wrapper's executable JAR - has class files for the wrapper and is started by start script.
gradle/wrapper/gradle-wrapper.properties: has configuration for the wrapper. This file specifies which version of Gradle to be used for the builds and where to download from.
build.gradle.kts: It's an entrypoint for gradle to get started.
All these files must be committed to version control or in the source code directory which is to be shipped.