compileGroovy task can't find Groovy library

(Eugene Dvorkin) #1

I am trying to compile mixed java-groovy project using groovy compilation and it’s failing with error

$ gradle jar
:compileJava SKIPPED
:compileGroovy FAILED
You must assign a Groovy library to the 'groovy' configuration.

I got latest version of groovy and my build.gradle file has following snipped:

compileJava.enabled = false
 sourceSets {
  main {
     groovy {
    srcDir 'src/main/java'
  test {
   groovy {
    srcDir 'src/test/java'
  dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
 compile 'storm:storm:0.8.2'
    compile "org.mongodb:mongo-java-driver:2.10.0"
    compile 'mysql:mysql-connector-java:5.1.22'
    compile 'vertica:vertica-jdbc:6.0.1'
    compile 'org.codehaus.groovy:groovy-all:2.1.1'

I can’t make sence of error message. What is wrong with my build file and what I can do to resolve the issue?


(Peter Niederwieser) #2

This build script should work when using Gradle 1.4 or higher, but it looks like you are using an earlier Gradle version. In that case, the Groovy dependency has to go on the ‘groovy’ configuration, not on ‘compile’.