Currently, there are two ways that you can run Gradle from the command-line:
One option is to run the ‘gradle’ command. The problem with this command is that it is not aware of the wrapper settings, and may end up running the build with an incompatible version of Gradle to what the build expects. Another downside of using this command is that you have to manually upgrade your Gradle installation whenever the version that your builds use changes. This becomes complicated when you need to run multiple builds, each of which uses a different version of Gradle.
The other option is to run the ‘gradlew’ command checked into the root of the source tree. This addresses the problems with the ‘gradle’ command, as now the correct version of Gradle is automatically downloaded and installed for you. However, this approach has its own downsides, as now it is awkward to work in subdirectories of the build or to work with multiple builds.
For example, now rather than cd-ing to some subdirectory ‘some/sub/dir’ and running ‘gradle test’, you need to run ‘…/…/…/gradlew test’ from the subdirectory or ‘./gradlew -p some/sub/dir test’ from the root directory.
This feature is to add a third command that will eventually become a replacement for the ‘gradle’ command. It will live in the Gradle distribution, so you can add it to your ‘$PATH’ environment variable, which means that it will be convenient to use. It will understand the wrapper settings, so that it always uses the correct version of Gradle.
See GRADLE-1378 for more details.
Implementation
This command should be called ‘gradlew’ and should live in the ‘bin’ directory of the distribution, alongside the ‘gradle’ command. When invoked, this command should do the roughly the same as the tooling API’s ‘DistributionFactory’ to load up the wrapper settings and download the distribution. It can then use the ‘WrapperExecuter’ to invoke Gradle.
Extra credit
Create a minimal Gradle distribution that includes just this command and it’s runtime dependencies. This means that I can download and install a small Gradle launcher that is a few megabytes in size. I add this launcher to my path and it takes care of locating, downloading and installing all the other things that are required to run a Gradle build.