Here the following happens: gradle loads gretty-plugin JARs twice, class-loading gets confused and you get exceptions like GroovyCastException.

Exceptions when using Jacoco code coverage on JDK-8

If you get exceptions when using combination JDK-8 + Gradle 1.1x + Jacoco + Gretty, you are very likely hitting a problem of compatibility between JDK-8 and earlier versions of Jacoco. This is fixed by adding the following to your "build.gradle":

jacoco {
toolVersion = '0.7.1.201405082137'
}

or, if you don’t want to depend on concrete version of Jacoco and prefer to use the latest available version: