Search code examples
gradlegrailsgroovy

Unable to resolve dependency in a recent created grails project


when i try to build my project this is the trace of gradle:

:compileIntegrationTestJava NO-SOURCE
startup failed:
/src/integration-test/groovy/shit/UserFunctionalSpec.groovy: 11: 
unable to resolve class GebSpec 
@Integration

/src/integration-test/groovy/shit/UserServiceSpec.groovy: 6: unable to resolve class org.hibernate.SessionFactory
   import org.hibernate.SessionFactory

I can't understand why have this error, the project was created with grails cli:

grails create-app grails-rest --profile=rest-api --features=mongodb

And generated a simple Domain User class, and then generate-all with grails cli.

It is my build.gradle:

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:views-gradle:1.1.6"
    }
}

version "0.1"
group "shit"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.plugins.views-json"

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-codecs"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-datasource"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:mongodb"
    compile "org.grails.plugins:views-json"
    compile "org.grails.plugins:views-json-templates"
    console "org.grails:grails-console"
    profile "org.grails.profiles:rest-api"
    provided "org.grails.plugins:embedded-mongodb:1.0.2"
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails:grails-datastore-rest-client"
    testCompile "org.grails:grails-web-testing-support"
}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    addResources = true
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

I have tried to resolve my dependencies on debug mode but I can't see a more accurate error message. Why is my gradle having this issues if this is a new and clean project?


Solution

  • grails create-app grails-rest --profile=rest-api --features=mongodb

    Does not produce a file called /src/integration-test/groovy/shit/UserFunctionalSpec.groovy

    That test is apparently a Hibernate Geb test and you have neither of those dependencies.

    EDIT:

    The rest-api profile has a discrepancy with the generate-all command and the dependencies it provides. To continue working, simply delete the generated UserFunctionalSpec and UserServiceSpec. Please file an issue here