Jason
Jason

Reputation: 12283

Cannot infer groovy classpath when using gradle

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/

Upvotes: 24

Views: 15862

Answers (1)

tim_yates
tim_yates

Reputation: 171054

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'
}

Upvotes: 25

Related Questions