Install gradle on ubuntu - lightblueseas/linuxstuff GitHub Wiki
Install gradle with SDKMAN!
The description how to install SDKMAN! can be found here with the following command:
If you have installed SDKMAN! you can now install gradle with the following command:
sdk install gradle 5.6.4
As next step you can check the gradle installation. Enter the following command:
gradle -v
Install manually
In order to install Gradle on ubuntu, you need sudo privileges.
-
First you have to install the JDK. Install java jdk
-
Download Gradle release in the user temp folder:
wget https://services.gradle.org/distributions/gradle-5.6.4-all.zip -P ~/tmp
Now we can extract the zip file in the /opt/gradle
directory:
sudo unzip -d /opt/gradle ~/tmp/gradle-5.6.4-all.zip
Check that the Gradle files are extracted:
ls -al /opt/gradle/gradle-5.6.4
The output should look similar like the following:
drwxr-xr-x 9 root root 4096 Feb 1 1980 .
drwxr-xr-x 3 root root 4096 Jul 27 11:08 ..
drwxr-xr-x 2 root root 4096 Feb 1 1980 bin
drwxr-xr-x 5 root root 4096 Feb 1 1980 docs
-rw-r--r-- 1 root root 163129 Feb 1 1980 getting-started.html
drwxr-xr-x 2 root root 4096 Feb 1 1980 init.d
drwxr-xr-x 3 root root 4096 Feb 1 1980 lib
-rw-r--r-- 1 root root 55261 Feb 1 1980 LICENSE
drwxr-xr-x 2 root root 4096 Feb 1 1980 media
-rw-r--r-- 1 root root 802 Feb 1 1980 NOTICE
drwxr-xr-x 45 root root 4096 Feb 1 1980 samples
drwxr-xr-x 86 root root 4096 Feb 1 1980 src
Set environment variable GRADLE_HOME and add to PATH
There are several options to set environment variables on Linux but the preferred option is to set it in the file 'etc/environment'
sudo awk 'BEGIN{ printf "GRADLE_HOME=\"/opt/gradle/gradle-5.5.1\"" >> "/etc/environment" }'
source /etc/environment
Now we have to configure the PATH environment variable to include the Gradle bin directory. Therefore we create a new shell file named gradle.sh inside of the /etc/profile.d/ directory.
sudo vi /etc/profile.d/gradle.sh
insert the following:
export PATH=${GRADLE_HOME}/bin:${PATH}
write and quit with :wq!
. The gradle.sh will be sourced by the next shell start.
Now we have to make the gradle.sh executable with the following command:
sudo chmod +x /etc/profile.d/gradle.sh
source /etc/profile.d/gradle.sh
Verify the gradle installation
To verify that the installation has been successful we can execute the following command:
gradle -v
The output should look similar to the following:
------------------------------------------------------------
Gradle 5.6.4
------------------------------------------------------------
Build time: 2019-07-10 20:38:12 UTC
Revision: 3245f748c7061472da4dc184991919810f7935a5
Kotlin: 1.3.31
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 11.0.3 (Ubuntu 11.0.3+7-Ubuntu-1ubuntu219.04.1)
OS: Linux 5.0.0-21-generic amd64
That's it. You have installed Gradle.