Upgrading Grails 1.x to 2

  • 871 views
Uploaded on

Upgrading your grails app from a previous version to the new world of Grails 2.X …

Upgrading your grails app from a previous version to the new world of Grails 2.X
Tips on how to prepare, what to do, and gotchas that may pop up.
Presented on 7/22/13 at Gr8ConfUS in Minneapolis, MN

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
871
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
6
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. UPGRADING FROM GRAILS 1.X TO 2.X STORIES AND LESSONS LEARNED WillBuck,webdeveloper,virtuwell Twitter(@wbucksoft) Github(willbuck) Email(wbucksoft@gmail.com)
  • 2. A LITTLE ABOUT ME (WillBuck)
  • 3. OBLIGATORY COMPANY SHOUTOUT
  • 4. MINNESOTA NATIVE
  • 5. DISNEY WORLD JUNKIE
  • 6. PRO(?)-AM TRAMPOLINE DODGEBALLER
  • 7. GRAILS GUY
  • 8. SHARING TODAY: Case Study: 1.3.7 -> 2.1.0
  • 9. A LITTLE ABOUT WHAT WE DID 8 In-House Plugins (some dependenton others) 3 Core Applications (one consumer-facing, two internal) LOTS of testingoverhaul
  • 10. CHIME IN! Manyof you have done this, share your knowledge
  • 11. BRIEF INTRO: WHY ARE WE DOING THIS AGAIN?
  • 12. GRAILS 2.X (Wellduh)
  • 13. What's newinGrails 2.0 and above
  • 14. TESTABILITY This would be aprimaryreason to upgrade. Grails 2 introduced a*lot*of excellenttestingsupport, including... In memoryGORM (makingunittestingcriteriaQueries possible) Better Console Output Cleaner testreports Annotation based mockingmakes code more straight-forward (imho)
  • 15. SUPPORT Since much of the communityis movingforward with Grails 2, it willbe easier to: GetStackOverflow questions answered Getanew feature in aplugin Find talented developers familiar with your technology Etc.
  • 16. AND MORE! Groovy1.8 support(or 2.0 in Grails 2.2+) ORM improvements and more options (mongoDBfor example) Better defaultscaffolding(jQueryand HTML5) Easier date parsing Multiple DataSources Support Etc etc etc (read the docs, yo!)
  • 17. PREPARING TO UPGRADE: BRING THE RIGHT TOOLS
  • 18. DIRECTORY DIFF TOOL Kaleidoscope -http://www.kaleidoscopeapp.com/ BeyondCompare -http://www.scootersoftware.com/
  • 19. GVM Lets you jump between versions with ease gvm install grails [version] http://gvmtool.net/
  • 20. SOURCE CONTROL Know how to hop around and make incrementalprogress! Git, Mercurial, maybe SVN
  • 21. UNIT TESTS
  • 22. HOW TO BEGIN
  • 23. START FRESH
  • 24. SIDE BY SIDE vs IN-PLACE Generates new-style metafiles w/proper dependencies Testboth simultaneously Commithistorywillbe cleaner -single commitof merge back!
  • 25. grails upgrade IS DEAD TO YOU!
  • 26. GET THE TESTS PASSING FIRST
  • 27. NOTE: THAT WILL TAKE AWHILE
  • 28. FIRE IT UP!
  • 29. MERGING BACK
  • 30. THE CODE WHAT 2 WATCH 4
  • 31. COMMON ONES Can largelybe found in grails documentation Upgrading fromprevious versions of Grails
  • 32. HSQL -> H2 Changes in DataSource.groovy dataSource{ driverClassName="org.h2.Driver" username="sa" password="" }
  • 33. COMMAND OBJECT @VALIDATEABLE @Validateable classSearchCommand{ } Note- seehttp://jira.grails.org/browse/GRAILS-9162
  • 34. LOTS OF LITTLE THINGS
  • 35. The redirect() method now uses the grails.serverURL config setting
  • 36. Public methods in controllers willnow be treated as actions. If you don'twantthis, make them protected or private.
  • 37. ConfigurationHolder.config-> grailsApplication.config
  • 38. TESTING - A NEW WORLD ORDER
  • 39. INHERITANCE -> ANNOTATIONS //Grails1.xway classmyControllerTestsextendsGrailsUnitTestCase{ }
  • 40. INHERITANCE -> ANNOTATIONS @TestFor(MyController) @Mock([MyDomain]) classmyControllerTests{ voidtestSomething(){ //NoneedtomockDomain()anymore,justsaveaway! MyDomaintestInstance=newMyDomain(property:'value').save() defresult=controller.get() assertresult==testInstance } }
  • 41. OR CHECK OUT SOME GREAT PLUGINS! //Grails2.xway @TestFor(MyController) @Build([MyDomain,MyOtherDomain])//Build-test-datapluginisgreat! classmyControllerSpecextendsSpecification{ //BeSpock-tastic void"testSomething"(){ given:"Adomaininstancetoretrieve" MyDomaintestInstance=MyDomain.build(name:'Will.i.am') when:"AcallisissuedtoController.get" defresult=controller.get() then:"Wegettheexpecteddomaininstance" result==testInstance } }
  • 42. COMING SOON! Grails 2.3 -Spock byDefault! NewinGrails 2.3
  • 43. YOU MAY FIND SURPRISES...
  • 44. Note: if you do have test-pollution... Ted Naleid's Blog onFinding Test Pollution
  • 45. TOUGHER / LESS DOCUMENTED GOTCHAS
  • 46. PLUGIN DEPENDENCY DEFINITION
  • 47. APPLICATION.PROPERTIES - > BUILDCONFIG.GROOVY
  • 48. APPLICATION.PROPERTIES (BEFORE) #GrailsMetadatafile #SunMar2515:53:36CDT2012 app.grails.version=1.3.7 app.name=patient-application app.servlet.version=2.4 plugins.build-test-data=1.1.0 plugins.code-coverage=1.1.7 plugins.codenarc=0.5 plugins.database-migration=1.0 plugins.functional-test=1.2.7 plugins.greenmail=1.2.1 plugins.hibernate=1.3.7 plugins.jms=1.2 plugins.jmx=0.7 plugins.joda-time=1.2 plugins.jquery=1.4.1.1 plugins.mail=0.9 plugins.spock=0.5-groovy-1.7 plugins.spring-security-core=1.1 plugins.tomcat=1.3.7 plugins.ui-performance=1.2.2
  • 49. BUILDCONFIG.GROOVY (AFTER) plugins{ build":tomcat:$grailsVersion" compile":mail:1.0" compile":greenmail:1.3.2" compile":build-test-data:2.0.3" compile":codenarc:0.17" compile(":functional-test:2.0.RC1") compile":jms:1.2" compile":jmx:0.7.2" compile":joda-time:1.4" compile":spring-security-core:1.2.7.3" compile":ui-performance:1.2.2" runtime":database-migration:1.1" runtime":hibernate:$grailsVersion" runtime":quartz:0.4.2" test":spock:0.6" }
  • 50. APPLICATION.PROPERTIES (AFTER) #GrailsMetadatafile #MonMar1813:56:54CDT2013 app.grails.version=2.1.0 app.name=patient-application app.servlet.version=2.4
  • 51. RESOURCES PLUGIN
  • 52. Bydefault, JS, CSS, images etc are now managed bythe resources plugin. <r:layoutResources> <r:require modules="jquery-ui, blueprint">
  • 53. This can mean a*lot*of restructuringto your front-end file management.
  • 54. STRUCTURED PROPERTIES
  • 55. UNDERSCORES IN DOMAIN VARIABLES //ingrails-app/domain/my-package classSomeDomain{ //Alegitimateusecase StringtelephoneNumber StringtelephoneNumber_areaCode StringtelephoneNumber_prefix StringtelephoneNumber_lineNumber //Accidentaloopsies,butwon'tkillthings Stringname Stringname_sourceId //NOWwe'retalkingtrouble DatedateOfBirth StringdateOfBirth_sourceId }
  • 56. Discoveringthe shadowycorners...
  • 57. TRY DIGGING DEEPER...
  • 58. AND DEEPER.....
  • 59. BUT EVENTUALLY... in 1.3.7... the same???
  • 60. FIX IT AND LET IT GO
  • 61. TAKEAWAY POINTS
  • 62. TAKE YOUR TIME
  • 63. Tryto keep new feature developmentto aminimum
  • 64. Do aback-merge allatonce, rightbefore finishing. Communicate with your team!
  • 65. Take alook for existingdocs on how upgrade problems were solved...
  • 66. ... butknow thatsome problems willbe unique to your codebase.
  • 67. Don'tfear the source, love the source.
  • 68. If allelse fails, ask the communityif you getstuck!
  • 69. RESOURCES: (FYI there was no part2) Grails Docs: Upgrading FromPrevious Versions O`ReillyOpenFeedback Publishing: Programming Grails Ted Naleids Blog - Upgrading toGrails 2 Unit Testing Rob Fletchers Blog - Grails 2 UpgradePart 1 TechnipelagoBlog - Grails 1.3.7 to2.0.1 upgradeexperiences
  • 70. SPECIAL THANKS TO: Zan Thrash Zach Legein Zach Lendon Colin Harrington SenthilKumaran Team @ virtuwell and Mywife, Virginia
  • 71. THANKS FOR LISTENING! Anyquestions? Givemefeedback! http://tinyurl.com/gr8wbuck13 Myinfo(again) Twitter(@wbucksoft) Github(willbuck) Email(wbucksoft@gmail.com)