Search code examples
grailsgrails-orm

Grails Build Fail With Exception


I am using Grails 3.1.6 while trying a database migration I faced a build Fail. I Used grails dbm-generate-gorm-changelog createGame.groovy and here is the console output:

FAILURE: Build failed with an exception.

* What went wrong:
Task 'dbmGenerateGormChangelog' not found in root project 'gamereview'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED 

I manually added

compile 'org.grails.plugins:database-migration:2.0.0.RC4' and

compile 'org.liquibase:liquibase-core:3.3.2'   in 
`build.gradle`  file 

Is there any problem with the importing? Help Needed.

Solution:

Added classpath 'org.grails.plugins:database-migration:2.0.0.RC4' in main section in build.gradle. That solved the Probelm.


Solution

  • Plugins with commands (this includes database-migration and hibernate and a few others) need to be in the 'main' dependencies block (with other plugins and regular jar dependencies) so the classes are available to the running app, but since Gradle runs the commands they also need to be in the dependencies block in the buildscript block, e.g.

    buildscript {
       repositories {
          mavenLocal()
          maven { url 'https://repo.grails.org/grails/core' }
       }
       dependencies {
          classpath "org.grails:grails-gradle-plugin:$grailsVersion"
          ...
          classpath 'org.grails.plugins:database-migration:2.0.0.RC4'
       }
    }