'Running Groovy scripts from Gradle

I am using Gradle 1.6 which comes with Groovy 1.8.6 and here comes the problem, I want to execute groovy script which need Groovy 2+, but Gradle is running this script with his own groovy (1.8.6) and my custom task is failing.



Solution 1:[1]

If you want to run scripts that uses @Grab you have to add ivy to compiler task

configurations {
    ivy
}

dependencies {
    ivy 'org.apache.ivy:ivy:2.4.0'
}

tasks.withType(GroovyCompile) {
    groovyClasspath += configurations.ivy
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mattias Olofsson