How to Install Gradle

Gradle is a dependency management / build tool that combines the best of Maven and Ant, making it an extremely powerful and customizable tool. It also uses a sleek Groovy DSL instead of the XML approach of Maven and Ant and is my personal tool-of-choice when I start a new project. Here’s how to install. I have some links to other gradle tutorials at the bottom of this post.

1. Install Java

First you need to have the Java JDK (Java Development Kit) installed; having the JRE (Java Runtime Environment) is not enough. To check if you have the JDK installed, open a command prompt or terminal and type javac -version. If you have a JDK installed, you will see your javac version output, eg. javac 1.7.0_01. If you get an error that javac is not a recognized command, download and install the Java JDK.

2. Download Gradle

Download from Gradle site

3. Unpack and Set System variables
Windows
  1. Unzip the Gradle download to the folder to which you would like to install Gradle, eg. “C:\Program Files”. The subdirectory gradle-x.x will be created from the archive, where x.x is the version.
  2. Add location of your Gradle “bin” folder to your path. Open the system properties (WinKey + Pause), select the “Advanced” tab, and the “Environment Variables” button, then add “C:\Program Files\gradle-x.x\bin” (or wherever you unzipped Gradle) to the end of your “Path” variable under System Properties. Be sure to omit any quotation marks around the path even if it contains spaces. Also make sure you separated from previous PATH entries with a semicolon “;”.
  3. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. C:\Program Files\Java\jdk1.7.0_06 and that %JAVA_HOME%\bin is in your Path environment variable.
  4. Open a new command prompt (type cmd in Start menu) and run gradle –version to verify that it is correctly installed.
Mac/Linux
  1. Extract the distribution archive, i.e. gradle-x.x-bin.tar.gz to the directory you wish to install Gradle. These instructions assume you chose /usr/local/gradle. The subdirectory gradle-x.x will be created from the archive.
  2. In a command terminal, add Gradle to your PATH variable: export PATH=/usr/local/gradle/gradle-x.x/bin:$PATH
  3. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.7.0_06 and that $JAVA_HOME/bin is in your PATH environment variable.
  4. Run gradle –version to verify that it is correctly installed.

You now have Gradle set up! Check out our post on how to build a simple Java web application using Gradle. I have several other Gradle tutorials available.

More reading:

Gradle – Installation Instructions
Gradle – Users Guide
Tagged with: , ,
Posted in Gradle
  • Igor

    Hi,

    I am trying to install gradle on openSuse. I followed the instructions, unzip, added bin folder to path, but when I run gradle I get:

    :~> gradle

    FAILURE: Build aborted because of an internal error.

    * What went wrong:

    Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.

    * Try:

    Run with –debug option to get additional debug info.

    * Exception is:

    net.rubygrapefruit.platform.NativeException: Could not open terminal for stdout: could not get termcap entry

    at net.rubygrapefruit.platform.internal.TerminfoTerminal.init(TerminfoTerminal.java:49)

    at net.rubygrapefruit.platform.internal.WrapperTerminal.init(WrapperTerminal.java:41)

    at net.rubygrapefruit.platform.internal.AbstractTerminals.getTerminal(AbstractTerminals.java:35)

    at org.gradle.internal.nativeplatform.console.NativePlatformConsoleDetector.getConsole(NativePlatformConsoleDetector.java:42)

    at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:32)

    at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:27)

    at org.gradle.logging.internal.OutputEventRenderer.attachConsole(OutputEventRenderer.java:68)

    at org.gradle.logging.internal.DefaultLoggingManager.attachConsole(DefaultLoggingManager.java:149)

    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:168)

    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)

    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)

    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)

    at org.gradle.launcher.Main.doAction(Main.java:48)

    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)

    at org.gradle.launcher.Main.main(Main.java:39)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:601)

    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)

    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)

    at org.gradle.launcher.GradleMain.main(GradleMain.java:26)

    Any advice?

  • Andrew J

    Where is my local folder on mac?! ps i run mavericks

Follow Me
RSS FeedFollow me on Twitter
Sponsored
Categories