Over a million developers have joined DZone.

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

Get the Edge with a Professional Java IDE. 30-day free trial.

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

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

gradle:goodness ,gradle ,wrapper

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}