How to Install Gradle on Manjaro
Gradle is a popular build automation tool for Java projects. In this tutorial, we will guide you through the process of installing Gradle on Manjaro, a Linux distribution based on Arch Linux.
Prerequisites
- Manjaro Linux installed
- Terminal or Command Line Interface (CLI)
Installing Gradle
Open your terminal
Ensure your system is updated by running the following command:
sudo pacman -SyuInstall Gradle by running the following command:
sudo pacman -S gradleVerify the installation by checking the version of Gradle:
gradle --versionIf Gradle is successfully installed, you will see the version number and other information about the installation.
Configuring Gradle
Once Gradle is installed, you may want to configure it to suit your needs. Here are a few common configurations:
Setting the Gradle Home Directory
You can set the Gradle home directory to a specific location by exporting an environment variable. For example, to set the Gradle home directory to /usr/local/gradle, run the following command:
export GRADLE_HOME=/usr/local/gradle
Using a Specific Version of Gradle
If you need to use a particular version of Gradle, you can set it up by creating a symlink to the desired version. For example, to use Gradle version 7.1.1, run the following commands:
sudo pacman -S gradle7
sudo ln -s /usr/share/java/gradle-7.1.1/bin/gradle /usr/local/bin/gradle
Configuring the Gradle Wrappers
Gradle also provides a feature called Gradle Wrapper that allows you to distribute your project without requiring the recipient to install Gradle. The wrapper is a script that calls the Gradle executable, and it is generated by running the wrapper task.
By default, the Gradle Wrapper script points to the version of Gradle that was used to generate it. However, you can configure it to use a specific version by modifying the gradle-wrapper.properties file.
To modify the gradle-wrapper.properties file, follow these steps:
Navigate to the root directory of your Gradle project.
Locate the
gradle/wrapperdirectory and open thegradle-wrapper.propertiesfile.Modify the
distributionUrlproperty to specify the URL of the Gradle distribution you want to use.For example, to use Gradle version 7.1.1, set the
distributionUrlproperty to:distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zipRun the
wrappertask to regenerate the Gradle Wrapper script:./gradlew wrapperThis will generate a new
gradlewscript that points to the specified version of Gradle.
Conclusion
In this tutorial, you learned how to install and configure Gradle on Manjaro Linux. With Gradle, you can build and automate your Java projects more efficiently.