Setting groovy version depending on gradle version

I want to build a project having a dependency on gradle 2.1:

compile(‘org.codehaus.groovy:groovy-all:2.3.9’) { force = true }

but I get Caused by:

groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.6 and you are trying to load version 2.3.9

Is there any solution to this at all, or can only the groovy2.x version be used that ships with gradle? Is it somehow possible to define a dependency on the groovyVersion bundled with gradle, similar to:

compile gradleApi()

maybe

compile groovy()

This is related to this question: http://forums.gradle.org/gradle/topics/conflicting-groovy-versions-when-running-jetty