The grails-view-tools has _Events.groovy that show how we can first put the project into a structure that more closely alligns with Grails 2.This will make it easier to merge changes up from grails2 branch to 3. moving src/groovy to src/main/groovy. and then tests. see the scripts/Grails3Prep.groovy.
- move the files as per the Grails3Prep.groovy
- move as much out of the "XyzPlugin.groovy" class as possible. closures can be put in a utility class with static methods and then have the deligate passed to for setting up spring beans for example. Then changes to this file can be better merged
- for pubished plugins that have test stuff, better to move them to a very minimal test-projects/app for integration testing so we don't polute the main plugin sources
see http://docs.grails.org/latest/guide/upgrading.html#upgrading2x and this excellent write up http://philip.yurchuk.com/software/upgrading-to-grails-3/ Don't pay attention to what they say in steps 2. we are upgrading the project/plugin in the same dir so we don't loose git history. These addendum steps also assume that
- create a stock project/plugin to be used to copy files into
- create a copy of the current project to convert to refere back to and merge files
- remove all empty dirs and dirs that are not needed
- delete grails-app/conf, and web-app
- remove application.properties and old gradle/grails files that are not needed in the root dir
copy from stock grails3 project files in
- build.gradle, gradle.properties, gradlew, gradlew.bat, settings.gradle and /gradle/
- grails-app/conf, grails-app/controllers/URLMappings.groovy and grails-app/init
- the XXXPlugin.groovy file from src/main/groovy/xyz package. Rename it appropriately.
merge and get it compiling
- update source for packages org.codehaus.groovy.grails -> org.grails and org.codehaus.groovy.grails.commons.GrailsApplication -> rails.core.GrailsApplication
- merge dependencies from backup buildConfig.groovy into gradle.groovy
- merge any config.groovy into application.yml(groovy). also merge in any XXXDefaultCongfig.groovy if using the plugin-config plugin
- copy your grails-app/conf/spring/resources.groovy back in if its being used
- rename package in init
- merge bootStrap.groovy into init/bootStrap if using it
- merge in the XXXPlugin.groovy files.
Integration Tests
- extend from Specification and add the @Integration annotation
- create-integration-test in new Grails 3 project to see example
- Use GrailsWebEnvironment.bindRequestIfNull(grailsApplication.mainContext,writer) in def setup() if needed.