Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

Atomist automates your software deliver experience. It's how modern teams deliver modern software.

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
:wrapper

BUILD SUCCESSFUL

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
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip


Get the open source Atomist Software Delivery Machine and start automating your delivery right there on your own laptop, today!

Topics:
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 }}