Gradle - Installation


Advertisements

Gradle is a build tool which is build based on java. There are some prerequisites that to be installed before installing the Gradle frame work.

Prerequisites

JDK and Groovy are the prerequisites for Gradle installation.

  • Gradle requires JDK version 6 or later to be installed in your system. It uses the JDK libraries which is installed and sets to the JAVA_HOME environmental variable.

  • Gradle carries its own Groovy library, therefore, we do no need to install Groovy explicitly. If it is installed, that is ignored by Gradle.

Following are the steps to install Gradle in your system.

Step 1 − Verify JAVA Installation

First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute Java –version command in any of the platform you are working on.

In Windows −

Execute the following command to verify Java installation. I have installed JDK 1.8 in my system.

C:\> java -version

Output −

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)

In Linux −

Execute the following command to verify Java installation. I have installed JDK 1.8 in my system.

$ java - version

Output −

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)

We assume the readers of this tutorial have Java SDK version 1.8.0_66 installed on their system.

Step 2 − Download Gradle Build File

Download the latest version of Gradle from the Download Gradle link. In the reference page, click on the Complete Distribution link. This step is common for any platform. For this you will get the complete distribution file into your Downloads folder.

Step 3 − Set Up Environment for Gradle

Setting up environment means that we have to extract the distribution file, copy the library files into proper location. Setting up GRADLE_HOME and PATH environmental variables.

This step is platform dependent.

In Windows −

Extract the downloaded zip file named gradle-2.11-all.zip and copy the distribution files from Downloads\gradle-2.11\ to C:\gradle\ location.

After that add the C:\gradle and C:\gradle\bin directories to the GRADLE_HOME and PATH system variables. Follow the given instruction that is right click on my computers -> click on properties -> advanced system settings -> click on environmental variables. There you will find a dialog box for creating and editing system variables. Click on new button for creating GRADLE_HOME variable (follow the left side screenshot). Click on Edit for editing the existing Path system variable (follow the right side screenshot). Follow the below given screenshots.

Setup Environment for Gradle

In Linux −

Extract the downloaded zip file named gradle-2.11-all.zip then you will find an extracted file named gradle-2.11.

You can use the following to move the distribution files from Downloads/gradle-2.11/ to /opt/gradle/ location. Execute this operation from the Downloads directory.

$ sudo mv gradle-2.11 /opt/gradle

Edit the ~/.bashrc file and paste the following content to it and save it.

export ORIENT_HOME = /opt/gradle
export PATH = $PATH:

Execute the following command to execute ~/.bashrc file.

$ source ~/.bashrc

Step 4: Verify the Gradle installation

In windows:

You can execute the following command in command prompt.

C:\> gradle –v

Output: there you will find the Gradle version.

------------------------------------------------------------
Gradle 2.11
------------------------------------------------------------

Build time: 2016-02-08 07:59:16 UTC
Build number: none
Revision: 584db1c7c90bdd1de1d1c4c51271c665bfcba978
Groovy: 2.4.4

Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_60 (Oracle Corporation 24.60-b09)
OS: Windows 8.1 6.3 amd64

In Linux:

You can execute the following command in terminal.

$ gradle –v

Output: there you will find the Gradle version.

------------------------------------------------------------
Gradle 2.11
------------------------------------------------------------

Build time: 2016-02-08 07:59:16 UTC
Build number: none
Revision: 584db1c7c90bdd1de1d1c4c51271c665bfcba978

Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_60 (Oracle Corporation 24.60-b09)
OS: Linux 3.13.0-74-generic amd64 
Advertisements