Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Gradle on Ubuntu 12.04

I am trying to install Gradle on Ubuntu 12.04. At first I used the package in the repository, but after hitting this bug it turned out I'd better use a more recent version.

I have removed the built-in package and installed gradle by copying the official 1.0 package into the /usr/local/share/ directory and adding a soft link from /usr/local/bin/gradle/ to /usr/local/share/gradle-1.0/bin/gradle.

It appears to work, but I run into a classpath problem. Namely as soon as I try to build a project I get

Exception executing org.gradle.api.internal.tasks.compile.ApiGroovyCompiler@1ab95774 in compiler daemon: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileGroovy'.
> org/apache/commons/cli/ParseException

Now locate commons-cli.jar gives me

/usr/share/groovy/lib/commons-cli.jar
/usr/share/java/commons-cli.jar

Apparently those two JARs are not on the classpath. Normally I would run a Java executable with the -cp options to add stuff to the classpath. But the gradle executable itself is a script that sets the classpath on its own before calling Java.

What is the correct way to install Gradle and make it find everything that needs on its classpath?

Please, note that I am a complete newbie to the JVM world, so do not assume I am familiar with anything :-)

like image 224
Andrea Avatar asked Jul 17 '12 17:07

Andrea


1 Answers

It turned out to be enough to put

groovy group: 'commons-cli', name: 'commons-cli', version: '1.0'

under dependencies

like image 123
Andrea Avatar answered Sep 28 '22 07:09

Andrea