Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot infer groovy classpath when using gradle

Tags:

I have a trivial Gradle project:

apply plugin: 'groovy'
apply plugin: 'application'

mainClassName = 'HelloWorld'

With one Groovy source file in src/main/groovy:

public class HelloWorld {
    public static void main(String[] args) {
        print "hello world"
    }
}

I type gradle run and get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Cannot infer Groovy class path because no Groovy Jar was found on class path: [/Users/jzwolak/files/experimenting/gradle/groovy-project/build/classes/java/main]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 0s
1 actionable task: 1 executed

How do I configure the Groovy classpath for Gradle?

I have Groovy at /usr/local/opt/groovy/libexec/

like image 951
Jason Avatar asked Mar 05 '18 22:03

Jason


1 Answers

You need to declare a groovy dependency, as in the documentation https://docs.gradle.org/current/userguide/groovy_plugin.html#sec:groovy_dependency_management

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.4.14'
}
like image 82
tim_yates Avatar answered Dec 23 '22 19:12

tim_yates