Upgrading Grails 5 to Grails 6
Initial things (Proper writeup to follow)
profiles are gone, use create-plugin or create-restapi from grails CLI (Steve says create-restapi may be best for plugins, with a changed up publishing block...?)
Versions used
Grails version 6.1.1
Gradle version 7.6.3
Java version 17.0.6-tem
Groovy version 3.0.11
TWO APPROACHES – UPGRADE IN PLACE OR FRESH BUILD
Fresh build
Use grails cli to start a new grails 6 application with the right name.
Ensure gradle wrapper properties using 7.6.3 and set networkTimeout=10000
Move everything except gitignore and README from grails cli into a "service" directory, since this is the shape our modules are previously
In build.gradle
Comment out "application" block
Comment out java sourceCompatibility block
Copy across
Group
Plugins/repositories
Configurations
"Custom deps" which definitely don't intefere with the bootstrapped grails 6 deps
Buildscript
NOTE - buildProperties no longer exists so for now comment out the generate descriptors blocks. Needs some input from Steve on how to proceed. (THIS NEEDS SORTING BEFORE RELEASE)
./gradlew clean to check everything builds
Then work through dependencies in original app, cross referencing to new app's ones, and vice versa. Make changes, additions and comment out unnecessary ones
It is IMPORTANT to do this in both directions. There may be newer grails 6 dependencies that supercede older ones, so go through line by line in the "core" deps list and try to understand whether a dependency is missing because it's been superceded, or included because it's now no longer drawn in automatically via other deps etc etc.
The "custom dependencies" list can likely be pulled over verbatim though.
dependencies block:
Check grails gradle plugin version lines up with grailsVersion
Change hibernate5 plugin over to
classpath "org.grails.plugins:hibernate5:$gormVersion"
- ensure gormVersion exists (see below)
Change plugin views-gradle over to
classpath "org.grails.plugins:views-gradle:3.1.2" /// Uh oh, this is breaking in grails-okapi
Possible exceptions
move spring-security core into the "proper" dependencies block and bump version up to grails version
implementation("org.grails.plugins:spring-security-core:${grailsVersion}")
Was in place to handle security issues present in grails 5
make sure web-toolkit and grails okapi are on grails6 versions (TBD on release)
MAKE SURE you copy across the profile declaration. This is no longer supplied by the CLI, so we need to make sure its there.
On that note, delete the grails cli yaml file
Copy over bootJar.enabled stuff and eclipse block
May need to remove anything referencing configScript, as this appears to have been removed
Wrap the
generateDescriptors
task in
since there has been a change to the buildProperties task in grails 6.
Ensure HikariCP dep is on 5.1.0, and change application.yml (And any other profile ymls) datasource properties to just:
The rest is superfluous at this point, and the defaults are performant
AT THIS STAGE, it may be beneficial to copy across the .git dir, and to set up a branch for your changes
Copy over grails-app directories one by one, and also src folder and anything else that has been removed
For apps gradle.properties
Copy across everything but the grailsVersion and grailsGradlePluginVersion from existing repo (ENSURE that groovy version lines up though)
Grails gradle plugin version should == grailsVersion
Gorm version to 8.0.3
Upgrade in place (Much faster and seemingly equivalent)
Bump gradle wrapper to 7.6.3, set networkTimeout=10000 and make same changes to gradle.properties as above
Work through build.gradle in the same way as above
gradlew clean and run.