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

Installing Gradle

  1. Open your terminal

  2. Ensure your system is updated by running the following command:

    sudo pacman -Syu
    
  3. Install Gradle by running the following command:

    sudo pacman -S gradle
    
  4. Verify the installation by checking the version of Gradle:

    gradle --version
    

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

  1. Navigate to the root directory of your Gradle project.

  2. Locate the gradle/wrapper directory and open the gradle-wrapper.properties file.

  3. Modify the distributionUrl property to specify the URL of the Gradle distribution you want to use.

    For example, to use Gradle version 7.1.1, set the distributionUrl property to:

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
    
  4. Run the wrapper task to regenerate the Gradle Wrapper script:

    ./gradlew wrapper
    

    This will generate a new gradlew script 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.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!