Gradle Goodness: Specify Wrapper Version and Distribution Type From the Command Line

DZone 's Guide to

Gradle Goodness: Specify Wrapper Version and Distribution Type From the Command Line

Gradle's built-in task wrapper allows others to build without needing to install Gradle itself. See how it's done and how you can incorporate it.

· Java Zone ·
Free Resource

Gradle has the built-in task wrapper to create a Gradle wrapper. The Gradle wrapper can be part of our project so other people can build our project with Gradle, without the need for them to install Gradle. Also, if we specify the Gradle wrapper, we can make sure the correct Gradle version is used.

To specify the version we must use the option --gradle-version. This version can be different than the Gradle version we use to create the Gradle wrapper. Since Gradle 3.1, we can also specify the distribution type of the Gradle wrapper. We can choose between a binary distribution or the all distribution, which contains documentation and source code. IDEs especially like to have the all distribution type so they can provide better help in their editors.

Image title

With the following wrapper command, we create a wrapper for Gradle 3.1 and the all distribution type. For a binary distribution, we either use the value bin or we don't specify the option, so Gradle falls back to the default value bin.

$ gradle wrapper --gradle-version 3.1 --distribution-type all


Total time: 1.012 secs


We can check the file gradle/wrapper/gradle-wrapper.properties and look for the key distributionUrl. We see the value points to the correct Gradle version and distribution type.

$ more gradle/wrapper/gradle-wrapper.properties
#Mon Sep 19 15:26:27 CEST 2016

gradle, gradle:goodness, wrapper

Published at DZone with permission of Hubert Klein Ikkink , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}