I want to add spock to my buildSrc code. After adding the spock dependencies, I get the above error when I run ‘gradle test’.
If I rename buildSrc to any other name, it works, spock runs, no groovy version conflict.
If I rename buildSrc to foo, cd foo and gradle test, it works. If I rename foo back to buildSrc, cd buildSrc and gradle test, it fails with the version problem.
What is special about the folder being named buildSrc and how does that affect the groovy version?
Here’s my buildSrc/build.gradle
apply plugin: 'groovy'
apply plugin: 'eclipse'
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
compile(group: 'com.google.code.gson', name: 'gson', version: '2.2.4')
compile(group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5')
compile(group: 'commons-lang', name: 'commons-lang', version: '2.6')
compile(group: 'commons-io', name: 'commons-io', version: '2.4')
compile(group: 'commons-collections', name: 'commons-collections', version: '3.2.1')
compile(group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.2')
compile(group: 'com.nativelibs4java', name: 'bridj', version: '0.6.2')
compile(group: 'com.typesafe', name: 'config', version: '1.0.2')
// mandatory dependencies for using Spock
groovy "org.codehaus.groovy:groovy-all:2.1.7"
testCompile "org.spockframework:spock-core:1.0-groovy-2.0-SNAPSHOT"
// optional dependencies for using Spock
testCompile "org.hamcrest:hamcrest-core:1.3" // only necessary if Hamcrest matchers are used
testRuntime "cglib:cglib-nodep:2.2.2"
// allows mocking of classes (in addition to interfaces)
testRuntime "org.objenesis:objenesis:1.2"
// allows mocking of classes without default constructor (together with CGLIB)
}