grails-gradle-plugin-archived icon indicating copy to clipboard operation
grails-gradle-plugin-archived copied to clipboard

Grails 2.5.1 causes exception: unable to resolve class spock.lang.Specification

Open neilabdev opened this issue 9 years ago • 6 comments

Thanks in advance for the great plugin and any assistance you may provide. I'm not entirely sure if this is a grails-gradle-plugin, but can verify that the simple attach test works with standard grails test-app command. After converting a larger project to grails 2.5.1 from 2.4.4, I noticed gradle was broken with the same exception, that being unable to find spock.lang.Specification. I have attached a sample project, though here is my build config:

buildscript {
        repositories {
                jcenter()
        }
        dependencies {
                classpath "org.grails:grails-gradle-plugin:2.1.2"
        }
}

// Apply the java plugin to add support for Java
apply plugin: 'grails'
version "0.1"
group "appName"
// In this section you declare where to find the dependencies of your project
repositories {
        grails.central()
        mavenCentral()
}

grails {
 grailsVersion = '2.5.1'
    groovyVersion = '2.4.4'
        springLoadedVersion '1.2.0.RELEASE'
}

// In this section you declare the dependencies for your production and test code
dependencies {
        compile fileTree(dir: 'lib', include: '*.jar')
       runtime('org.grails.plugins:hibernate4:4.3.10') { exclude module: 'xml-apis'  }
        bootstrap "org.grails.plugins:tomcat:7.0.55.3" // or ":tomcat:8.0.22"

        // plugins for the compile step
        compile "org.grails.plugins:scaffolding:2.1.2"
        compile 'org.grails.plugins:cache:1.1.8'
        compile "org.grails.plugins:asset-pipeline:2.2.3"

        runtime "org.grails.plugins:database-migration:1.4.0"
        runtime "org.grails.plugins:jquery:1.11.1"
}
tasks.withType(org.grails.gradle.plugin.tasks.GrailsWarTask) { Task t ->
        t.outputFile = new File("build/distributions/${project.name}.war")
}

tasks.withType(org.grails.gradle.plugin.tasks.GrailsTask) { Task t ->
        t.jvmOptions {
                jvmArgs "-XX:MaxPermSize=256m", "-Xmx1024m", "-Xms512m", "-XX:+CMSClassUnloadingEnabled", "-XX:+HeapDumpOnOutOfMemoryError"
        }
}

And a working project, which runs using 'grails test-app integration: ' but fails with 'gradle test' with the following message:

| Error Compilation error compiling [unit] tests: startup failed:
/Users/ghost/Documents/projects/ic2/test-validation/test/unit/test/validation/ChildSpec.groovy: 4: unable to resolve class spock.lang.Specification
 @ line 4, column 1.
   import spock.lang.Specification
   ^

/Users/ghost/Documents/projects/ic2/test-validation/test/unit/test/validation/MotherSpec.groovy: 4: unable to resolve class spock.lang.Specification
 @ line 4, column 1.
   import spock.lang.Specification
   ^

/Users/ghost/Documents/projects/ic2/test-validation/test/unit/test/validation/ParentSpec.groovy: 4: unable to resolve class spock.lang.Specification
 @ line 4, column 1.
   import spock.lang.Specification
   ^

3 errors
 (Use --stacktrace to see the full trace)
:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 26.72 secs

Here is sample project:

https://s3-us-west-2.amazonaws.com/neilab/uploads/test-validation.zip

neilabdev avatar Aug 05 '15 12:08 neilabdev

Apparently this happens even with new apps bootstrapped by gradle itself.

neilabdev avatar Aug 06 '15 13:08 neilabdev

+1

issue2k avatar Aug 18 '15 08:08 issue2k

+1

acoveny avatar Nov 04 '15 07:11 acoveny

+1

anti43 avatar Jan 25 '16 06:01 anti43

+1

elkhorn360 avatar Mar 02 '16 09:03 elkhorn360

+1. Same issue with grails 2.5.5

vijaysl avatar Sep 20 '16 17:09 vijaysl