Raspberry Pi

How to Install Gradle on Raspberry Pi

Gradle is a general-purpose, open-source tool for building almost any software. It helps the team build, automate, and deliver software faster. Further, it supports multiple programming languages, including Java, C++, C and more and uses the Groovy and Kotlin languages for defining the project and building the scripts.

If you want to start using your Raspberry Pi device for software-building purposes, you can install Gradle on Raspberry Pi through this article’s guidelines.

How to Install Gradle on Raspberry Pi

To install Gradle on Raspberry Pi, follow the below-given steps:

Step 1: Install Java on Raspberry Pi

Gradle needs Java to perform operations on the Raspberry Pi system. Therefore, you must install it using the following command:

$ sudo apt install default-jdk -y

To confirm Java installation, follow the below-given command:

$ java --version

Step 2: Download Gradle Source File on Raspberry Pi

Visit the Gradle release page and check the latest version so that you can download it using the wget command.

The latest version of Gradle at the time of writing this article is 7.6, which can be downloaded in the /tmp directory through the following command:

$ wget https://services.gradle.org/distributions/gradle-7.6-bin.zip -P /tmp

Step 3: Unzip the Gradle Zip File

Now we are going to unzip the Gradle zip file at location /opt/gradle, where all unbundled packages are placed:

$ sudo unzip -d /op/gradle /tmp/gradle-7.6-bin.zip

Step 4: Setup Environment Variable for Gradle

You must need to tell the system where the Gradle is placed so that you will be able to run the application. To do this, you must create a “gradle.sh” script file inside the “/etc/profile.d” location using the following command:

$ sudo nano /etc/profile.d/gradle.sh

Inside the file, add the following lines inside the file to tell the system the path for Gradle on Raspberry Pi:

export GRADLE_HOME=/opt/gradle/gradle-7.6
export PATH=${GRADLE_HOME}/bin:${PATH}

Note: Don’t forget to replace the Gradle version.

You must save the file using “CTRL+X”, add “Y,” and press enter to exit.

Step 5: Make Gradle File Executable

You must make the Gradle file executable using the following command:

$ sudo chmod +x /etc/profile.d/gradle.sh

Afterward, load the changes you made to the file using the following command:

$ source /etc/profile.d/gradle.sh

Once the changes are applied, you can confirm the Gradle installation by running the following command:

$ gradle -v

The above output confirms the installation of Gradle on the Raspberry Pi system and you can start building software through it.

Conclusion

Gradle is an open-source tool for building and automating any software. You can install this tool by first installing Java on the Raspberry Pi system. Afterward, you must download the Gradle zip file from the official website and unzip it inside the /opt/gradle directory. You must set the path for Gradle inside an executable file and load the changes to install the tool on the Raspberry Pi system successfully.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.