Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None of the dbm-scripts are working with grails 6. #346

Open
2 tasks
tircnf opened this issue Feb 1, 2024 · 8 comments
Open
2 tasks

None of the dbm-scripts are working with grails 6. #346

tircnf opened this issue Feb 1, 2024 · 8 comments

Comments

@tircnf
Copy link

tircnf commented Feb 1, 2024

This is a known issue with all grails plugins after the upgrade to 6.

Task List

  • [ X] Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • [ X] Full description of the issue provided (see below)

Steps to Reproduce

  1. build a grails 6 app
  2. include this plugin.
  3. try any script.

Expected Behaviour

scripts should run.

Actual Behaviour

since the grails 6 upgrade, all plugins with scripts need to change to the new methodology.
Documentation needs to be updated.

Environment Information

  • Operating System: any
  • Grails Version: 6.1.1
  • Plugin Version: 4.2.1
  • Database: mysql
  • JDK Version: 11
@RxL-Nikhil-Kanyal
Copy link

@tircnf Did you get any resolution for this issue?

@tircnf
Copy link
Author

tircnf commented May 31, 2024

@RxL-Nikhil-Kanyal -- Not really. we haven't upgraded to 6 yet. I think your choices are to either stick with pre-6 grails, wait for the grails team to upgrade the plugin, or dig in and upgrade the plugin to use the new way grails runs scripts.

@matrei
Copy link
Contributor

matrei commented May 31, 2024

In Grails 6, the commands are available as Gradle tasks, for example:
./gradlew dbmGenerateChangelog -Pargs="changelog.groovy"

If not already present, add runtimeOnly 'org.grails.plugins:database-migration:4.2.1' to buildSrc dependencies to add the Gradle tasks.

Although, to run the database-migration:4.2.1 commands in Grails 6.2.0 you also need to add org.grails:grails-shell:6.1.2 to the buildSrc dependencies of your project, as grails-shell is still needed for 4.2.1 and was removed in Grails 6.2.0. Or use the 5.0.0-SNAPSHOT version of the database-migration plugin where grails-shell is no longer used.

Another caveat when running commands with 6.2.0 is that there is a bug in grails-bootstrap (after the upgrade to Groovy 3.0.21) when running commands. This bug is fixed by grails/grails-core#13472 and should be included in the next Grails release.

@tircnf
Copy link
Author

tircnf commented Aug 20, 2024

I think the arguments are in the incorrect order. Should it be
gradle runCommand -Pargs="dbm-generate-gorm-changelog changelog.groovy"

@matrei -- Are you saying in that last sentence that there is no way to currently get the scripts to run on grails 6.2?

Another caveat when running commands with 6.2.0 is that there is a bug in grails-bootstrap (after the upgrade to Groovy 3.0.21) when running commands. This bug is fixed by grails/grails-core#13472 and should be included in the next Grails release.

@matrei
Copy link
Contributor

matrei commented Aug 20, 2024

@tircnf

I think the arguments are in the incorrect order. Should it be
gradle runCommand -Pargs="dbm-generate-gorm-changelog changelog.groovy"

You can run commands that way too. Here is a guide on using application commands in Grails 6:
https://medium.com/@puneetbehl/a-comprehensive-guide-to-custom-application-command-in-grails-framework-f7496406ac50

Are you saying in that last sentence that there is no way to currently get the scripts to run on grails 6.2?

If you upgrade the Grails version 6.2.1-SNAPSHOT the fix should be in there.
There is work going on right now to get a 6.2.1 version released.

@jdaugherty
Copy link

Alternatively, as a temporary work around, here's a shell function I use to make it easy to call the original scripts:

function _grails() {
  local msg="$*";
  local gradleArgs=`print -l $msg`;
  gradle runCommand "-Pargs=$gradleArgs"
}

Then invoke the scripts like _grails dbm-gorm-diff test.groovy

@herrmartins
Copy link

I'm just learning grails now, because I got a job as junior dev in a company.. to learn I begin to use 6 and this issue was just blowing my mind.. HOw can we create an app by the forge app, and just don't work? Begining from the driver.. but ok...
grails 6.2.0
I did this:
implementation("org.grails:grails-shell:6.1.2")
implementation("org.grails.plugins:database-migration:4.2.1")

I do'nt know, if it is good, I don't understand much of the framwork.. it was ok to build like this.. it is running, debugging in vs code..

@jamesfredley
Copy link
Contributor

@herrmartins

You will also need to add the following to buildSrc/build.gradle (the way it comes from forge) or buildscript in your top level build.gradle (the older way).

classpath("org.grails.plugins:database-migration:4.2.1")
classpath("org.grails:grails-shell:6.1.2") // for database-migration

Then you can execute them with Grails Shell. org.grails.plugins:database-migration 4.2.1 and 5.0.0-SNAPSHOT have not been migrated fully to Gradle yet.

If you are using IntelliJ, you can execute via Run Grails Command

dbm-gorm-diff generated.groovy

Otherwise you can add grails wrapper, see https://github.com/orgs/grails/discussions/13583, and execute as

./grailsw dbm-gorm-diff generated.groovy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants