Unable to set compileGroovy:groovyClasspath property

Hi,

I am using gradle 1.4, and am trying to invoke a ‘compileGroovy’ task. My gradle.build file looks like this :

apply plugin: ‘groovy’ compileGroovy

{

source = fileTree(dir: ‘webapp/groovy’)

destinationDirectory = new File(‘webapp/WEB-INF/classes’)

}

On invoking , “gradle compileGroovy --debug”, I get the below Exception:

Caused by: org.gradle.api.InvalidUserDataException: ‘compileGroovy.groovyClasspath’ must not be empty. It is either configured automatically by the ‘groovy-base’ plugin, or can be set manually.

Now, the error is telling me to set the property , groovyClasspath. So, according to the docs (http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.compile.GroovyCompile.html#org.gradle.api.tasks.compile.GroovyCompile:groovyClasspath), ‘groovyClasspath’ is a ‘org.gradle.api.file.FileCollection’, which can be instantiated by using ‘Project.files(java.lang.Object…)’. But, I am unable to use the ‘files’ method on ‘org.gradle.api.Project’.

Any pointers on what am I doing wrong ?

Thanks much

P.S : I am relatively a newbie in both Gradle and Groovy.

Have you declared Groovy as a ‘compile’ dependency? The Groovy chapter in the Gradle User Guide shows how it’s done.

PS: Please use HTML code tags for all code.

Thanks for the suggestion. The error has disappeared after adding the compile dependency. The working build file looks like this now :

apply plugin: 'groovy'
repositories {
    mavenCentral()
}
dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.0.6'
}
compileGroovy
        {
            source = fileTree(dir: 'webapp/groovy')
            destinationDir = new File('webapp/WEB-INF/classes')
        }