Groovy 2.3.10 is not compatible with Spock 1.0.0-groovy-2.4, but I don’t know how to address this problem. Can someone help me please?
Here is the build.gradle file:
apply plugin: "groovy"
repositories {
mavenCentral()
}
dependencies {
// Get the gradle api definitions
// I will be writing a gradle plugin, so I figure I need this
compile gradleApi()
compile 'org.codehaus.groovy:groovy-all:2.4.3'
testCompile 'org.codehaus.groovy:groovy-all:2.4.3'
compile ('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude group: 'org.codehaus.groovy'
}
}
task wrapper(type: Wrapper) {
gradleVersion = "2.4"
}
Now when I type ./gradlew test, I get:
The Spock compiler plugin cannot execute because Spock 1.0.0-groovy-2.4 is not compatible with Groovy 2.3.10.
More info: ./gradlew --version
------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------
Build time: 2015-05-05 08:09:24 UTC
Build number: none
Revision: 5c9c3bc20ca1c281ac7972643f1e2d190f2c943c
Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM: 1.8.0_40 (Oracle Corporation 25.40-b25)
OS: Linux 2.6.32-358.el6.x86_64 amd64
You should really be using Groovy 2.3 here. Since this is going to be a Gradle plugin and use Gradle’s version of Groovy at runtime you should be compiling and testing against the Gradle Groovy distribution. In practice, it’s best to use the localGroovy() dependency notation to ensure this.
On a technical note, I think Spockframework should be in the testCompile configuration, otherwise your released plugin will have a dependency on SpockFw
I have similar issue trying to run gradle in Eclipse. Nothing in my code seems to ask for groovy 2.4 but somehow gradle is pulling it in. I know this because my “Gradle Dependencies (persisted)” includes groovy-all-2.4.4.jar. It seems that this is being pulled in via gradle 2.11.
I have the same problem. Groovy Eclipse only has compiler versions up to 2.4.3, but Gradle pulls in 2.4.4 which breaks running unit tests in Eclipse.Forcing groovy-all 2.4.3 with resolutionStrategy didn’t work either.
Yeah, you’re right.I had problems with that months ago, see my earlier post, but I don’t see them anymore. I assumed this was because my plugin install pulled them in, but it didn’t. I only have up to 2.4.3 but nothing complains about that anymore. Not sure why. Sorry I couldn’t be more helpful.
If you are building a plugin and don’t need the absolute llatest API functionality, your workaround is simply to use an older version of Gradle which will have 2.4.3 as it’s dependency.
Yes, I considered that. Going back to gradle 2.7 (2.6?) goes back to groovy
2.3.6. Unfortunately, the jump is from 2.3.6 to 2.4.4. I guess that is the
only option though. Even than it is a matter of having luck that gradle
2.3.x and the greclipse compiler 2.3.x matches.
I’m not sure it will help since there is a runtime check when running spock (or groovy?) that checks for exact match between groovy versions, i.e. for the groovy loaded in Eclipse and the groovy in the dependency list of the gradle project. But I will try it, thanks!
What went wrong:
A problem occurred evaluating root project ‘gradle-build-test’.
Cannot convert the provided notation to an object of type Dependency: build_dx1mkix5t1nts8t1hab7cczhv$_run_closure4$_closure13@16e1b652.
The following types/formats are supported:
- Instances of Dependency.
- String or CharSequence values, for example ‘org.gradle:gradle-core:1.0’.
- Maps, for example [group: ‘org.gradle’, name: ‘gradle-core’, version: ‘1.0’].
- FileCollections, for example files(‘some.jar’, ‘someOther.jar’).
- Projects, for example project(‘:some:project:path’).
- ClassPathNotation, for example gradleApi().
The syntax is wrong. Also for purpose of readability it is better to restrict place each dependency on a separate line along with the configuration it belogns to. i.e.