4

I have a running Grails application, started some years ago with Grails 2.0.0.RC1 and updated, version after version, to 2.2.5. After this update I worked only occasionally on it, since the project was "completed", doing only bug fixing.

Now I need to work a lot on it, so I'm planning to upgrade it to Grails 3.0 in order to use new features added in the latest releases of Grails.

This project has ~25 domain classes, ~20 controllers, a bunch of services, some custom taglibs and uses some plugins: jasper, shiro, searchable.

As a general suggestion, the documentation says that

The best approach to take when upgrading a plugin or application (and if your application is using several plugins the plugins will need upgrading first) is to create a new Grails 3.0 application of the same name and copy the source files into the correct locations in the new application.

Is this really the best approach for my case, or are there alternative ways (faster and less painful) to achieve this? Do you have already dealt with this? What you've done?

lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
  • This may help http://www.slideshare.net/SpringCentral/migrating-from-grails-2-to-grails-3 . This may give you some hints. I am also upgrading application with 35+ domains and 100+ controllers from grails 2.5.1 to 3.1.0. The pain is unbearable :( – sgiri Apr 05 '16 at 11:09
  • The link to the documentation no longer works. at least if you are forced to use Comcast: "Malware and Phishing This site is blocked because it is a known security threat. Please contact your network administrator to gain access." – sf_jeff May 03 '23 at 19:42

3 Answers3

4

Grails 3.0 is a complete ground up rewrite of Grails so, as also official documentation says, the best approach is to create a new application and then copy inside it sources file first (src/java, src/groovy, grails-app) and static assets to asset folder. Next you have to migrate the configuration (e.g. configuration in Config.groovy should be now in application.yml or application.groovy) and dependency files (BuildConfig.groovy to build.gradle).

The entire process is well described at official link you provide. Finally, as Emmanuel Rosa said above make sure the plugins you are using are all Grails 3.x compatible.

Clijsters
  • 4,031
  • 1
  • 27
  • 37
RickyGo
  • 166
  • 7
  • 1
    This is not helpful. I've already read the official documentation and also referenced to it in my question. My question is addressed to anybody has done a real grails 2->3 migration and that can tell me what issues he has really encountered. I've a limited time to do this, so I need to choose the right way, doing an estimation, before start. – lifeisfoo Sep 04 '15 at 10:45
  • I've experienced a migration from grails 2 to grails 3 and that's what I've done. I'm sorry if it does not helped you. – RickyGo Sep 04 '15 at 11:08
  • Have you just copied and pasted models, controllers, services, views and external java/groovy sources without any trouble? – lifeisfoo Sep 04 '15 at 11:40
  • Obviously it depends on the complexity of the application. Mine is simple (6 domain classes), so I follow step by step the documentation and all works quite fine. My old application was build on grails 2.1.1 so I have to change a little in controller (move code from list action to index), move dataSource configuration from DataSource.groovy to application.yml (using yaml syntax instead of groovy syntax). Another big difference is in the build system, so I've to learn Gradle and move and transform configuration from BuildConfig.groovy to build.gradle. Pay attention also to contentNegotiation. – RickyGo Sep 04 '15 at 12:37
  • @RickyGo Hi, your comments are at least as valuable as your answer, if not more. Could you include them in your answer? Thanks! – Eel Lee May 31 '17 at 13:52
2

Yes.

I upgraded a project from 2.2 to 2.4 and the thing would not work right until I created a new 2.4 project and copied everything over. I can't imagine success with the jump you're making using any other approach.

Just hunker down with your favorite snacks, open up a branch in your dvcs (git, mercurial, etc) and make steady progress. It won't be that bad. Your challenges will likely be configuration and missing plugins. Most artefacts such as domains and controllers will work unchanged.

Speaking of plugins, make sure all the ones you need are 3.0 compatible.

Emmanuel Rosa
  • 9,697
  • 2
  • 14
  • 20
0

For future references you can consider those links as reference:

Upgrading Grails 3

Grails 3 Upgrading from 3.2.x to 3.3.0

It's not impossible to upgrade from 2 to 3.

  1. You need to see the change log
  2. See change in the configuration and folder structure
  3. Have in mind new pluggins and outdated one
  4. Configure your IDE (if you used one) - gradle, groovy .. With Grails 3 Intellij seems to to be the best option
  5. At the end you need to test a lot - with empty base, with your legacy data,

For a small project took me one day for upgrading.

Vasil Koicev
  • 57
  • 1
  • 8