UPGRADING FROM
GRAILS 1.X TO 2.X
STORIES AND LESSONS LEARNED
WillBuck,webdeveloper,virtuwell
Twitter(@wbucksoft) Github(wi...
A LITTLE ABOUT ME
(WillBuck)
OBLIGATORY COMPANY SHOUTOUT
MINNESOTA NATIVE
DISNEY WORLD JUNKIE
PRO(?)-AM TRAMPOLINE DODGEBALLER
GRAILS GUY
SHARING TODAY:
Case Study: 1.3.7 -> 2.1.0
A LITTLE ABOUT WHAT WE DID
8 In-House Plugins (some dependenton others)
3 Core Applications (one consumer-facing, two inte...
CHIME IN!
Manyof you have done this, share your knowledge
BRIEF INTRO: WHY ARE
WE DOING THIS AGAIN?
GRAILS 2.X
(Wellduh)
What's newinGrails 2.0 and above
TESTABILITY
This would be aprimaryreason to upgrade.
Grails 2 introduced a*lot*of excellenttestingsupport, including...
In...
SUPPORT
Since much of the communityis movingforward with Grails 2, it
willbe easier to:
GetStackOverflow questions answere...
AND MORE!
Groovy1.8 support(or 2.0 in Grails 2.2+)
ORM improvements and more options (mongoDBfor
example)
Better defaultsc...
PREPARING TO UPGRADE:
BRING THE RIGHT TOOLS
DIRECTORY DIFF TOOL
Kaleidoscope -http://www.kaleidoscopeapp.com/
BeyondCompare -http://www.scootersoftware.com/
GVM
Lets you jump between versions with ease
gvm install grails [version]
http://gvmtool.net/
SOURCE CONTROL
Know how to hop around and make incrementalprogress!
Git, Mercurial, maybe SVN
UNIT TESTS
HOW TO BEGIN
START FRESH
SIDE BY SIDE
vs
IN-PLACE
Generates new-style metafiles w/proper dependencies
Testboth simultaneously
Commithistorywillbe c...
grails upgrade
IS DEAD TO YOU!
GET THE TESTS PASSING FIRST
NOTE: THAT WILL TAKE AWHILE
FIRE IT UP!
MERGING BACK
THE CODE
WHAT 2 WATCH 4
COMMON ONES
Can largelybe found in grails documentation
Upgrading fromprevious versions of Grails
HSQL -> H2
Changes in DataSource.groovy
dataSource{
driverClassName="org.h2.Driver"
username="sa"
password=""
}
COMMAND OBJECT @VALIDATEABLE
@Validateable
classSearchCommand{
}
Note- seehttp://jira.grails.org/browse/GRAILS-9162
LOTS OF LITTLE THINGS
The redirect() method now uses the grails.serverURL config
setting
Public methods in controllers willnow be treated as actions. If
you don'twantthis, make them protected or private.
ConfigurationHolder.config-> grailsApplication.config
TESTING - A NEW WORLD ORDER
INHERITANCE -> ANNOTATIONS
//Grails1.xway
classmyControllerTestsextendsGrailsUnitTestCase{
}
INHERITANCE -> ANNOTATIONS
@TestFor(MyController)
@Mock([MyDomain])
classmyControllerTests{
voidtestSomething(){
//Noneedt...
OR CHECK OUT SOME GREAT PLUGINS!
//Grails2.xway
@TestFor(MyController)
@Build([MyDomain,MyOtherDomain])//Build-test-datapl...
COMING SOON!
Grails 2.3 -Spock byDefault!
NewinGrails 2.3
YOU MAY FIND SURPRISES...
Note: if you do have test-pollution...
Ted Naleid's Blog onFinding Test Pollution
TOUGHER / LESS DOCUMENTED GOTCHAS
PLUGIN DEPENDENCY DEFINITION
APPLICATION.PROPERTIES - >
BUILDCONFIG.GROOVY
APPLICATION.PROPERTIES (BEFORE)
#GrailsMetadatafile
#SunMar2515:53:36CDT2012
app.grails.version=1.3.7
app.name=patient-app...
BUILDCONFIG.GROOVY (AFTER)
plugins{
build":tomcat:$grailsVersion"
compile":mail:1.0"
compile":greenmail:1.3.2"
compile":bu...
APPLICATION.PROPERTIES (AFTER)
#GrailsMetadatafile
#MonMar1813:56:54CDT2013
app.grails.version=2.1.0
app.name=patient-appl...
RESOURCES PLUGIN
Bydefault, JS, CSS, images etc are now managed bythe
resources plugin.
<r:layoutResources>
<r:require modules="jquery-ui, ...
This can mean a*lot*of restructuringto your front-end file
management.
STRUCTURED PROPERTIES
UNDERSCORES IN DOMAIN VARIABLES
//ingrails-app/domain/my-package
classSomeDomain{
//Alegitimateusecase
StringtelephoneNumb...
Discoveringthe shadowycorners...
TRY DIGGING DEEPER...
AND DEEPER.....
BUT EVENTUALLY...
in 1.3.7...
the same???
FIX IT AND LET IT GO
TAKEAWAY POINTS
TAKE YOUR TIME
Tryto keep new feature developmentto aminimum
Do aback-merge allatonce, rightbefore finishing. Communicate
with your team!
Take alook for existingdocs on how upgrade problems were
solved...
... butknow thatsome problems willbe unique to your codebase.
Don'tfear the source, love the source.
If allelse fails, ask the communityif you getstuck!
RESOURCES:
(FYI there was
no part2)
Grails Docs: Upgrading FromPrevious Versions
O`ReillyOpenFeedback Publishing: Programm...
SPECIAL THANKS TO:
Zan Thrash
Zach Legein
Zach Lendon
Colin Harrington
SenthilKumaran
Team @ virtuwell
and Mywife, Virginia
THANKS FOR LISTENING!
Anyquestions?
Givemefeedback! http://tinyurl.com/gr8wbuck13
Myinfo(again) Twitter(@wbucksoft) Github...
Upcoming SlideShare
Loading in...5
×

Upgrading Grails 1.x to 2

1,269

Published on

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,269
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Upgrading Grails 1.x to 2

  1. 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. 2. A LITTLE ABOUT ME (WillBuck)
  3. 3. OBLIGATORY COMPANY SHOUTOUT
  4. 4. MINNESOTA NATIVE
  5. 5. DISNEY WORLD JUNKIE
  6. 6. PRO(?)-AM TRAMPOLINE DODGEBALLER
  7. 7. GRAILS GUY
  8. 8. SHARING TODAY: Case Study: 1.3.7 -> 2.1.0
  9. 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. 10. CHIME IN! Manyof you have done this, share your knowledge
  11. 11. BRIEF INTRO: WHY ARE WE DOING THIS AGAIN?
  12. 12. GRAILS 2.X (Wellduh)
  13. 13. What's newinGrails 2.0 and above
  14. 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. 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. 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. 17. PREPARING TO UPGRADE: BRING THE RIGHT TOOLS
  18. 18. DIRECTORY DIFF TOOL Kaleidoscope -http://www.kaleidoscopeapp.com/ BeyondCompare -http://www.scootersoftware.com/
  19. 19. GVM Lets you jump between versions with ease gvm install grails [version] http://gvmtool.net/
  20. 20. SOURCE CONTROL Know how to hop around and make incrementalprogress! Git, Mercurial, maybe SVN
  21. 21. UNIT TESTS
  22. 22. HOW TO BEGIN
  23. 23. START FRESH
  24. 24. SIDE BY SIDE vs IN-PLACE Generates new-style metafiles w/proper dependencies Testboth simultaneously Commithistorywillbe cleaner -single commitof merge back!
  25. 25. grails upgrade IS DEAD TO YOU!
  26. 26. GET THE TESTS PASSING FIRST
  27. 27. NOTE: THAT WILL TAKE AWHILE
  28. 28. FIRE IT UP!
  29. 29. MERGING BACK
  30. 30. THE CODE WHAT 2 WATCH 4
  31. 31. COMMON ONES Can largelybe found in grails documentation Upgrading fromprevious versions of Grails
  32. 32. HSQL -> H2 Changes in DataSource.groovy dataSource{ driverClassName="org.h2.Driver" username="sa" password="" }
  33. 33. COMMAND OBJECT @VALIDATEABLE @Validateable classSearchCommand{ } Note- seehttp://jira.grails.org/browse/GRAILS-9162
  34. 34. LOTS OF LITTLE THINGS
  35. 35. The redirect() method now uses the grails.serverURL config setting
  36. 36. Public methods in controllers willnow be treated as actions. If you don'twantthis, make them protected or private.
  37. 37. ConfigurationHolder.config-> grailsApplication.config
  38. 38. TESTING - A NEW WORLD ORDER
  39. 39. INHERITANCE -> ANNOTATIONS //Grails1.xway classmyControllerTestsextendsGrailsUnitTestCase{ }
  40. 40. INHERITANCE -> ANNOTATIONS @TestFor(MyController) @Mock([MyDomain]) classmyControllerTests{ voidtestSomething(){ //NoneedtomockDomain()anymore,justsaveaway! MyDomaintestInstance=newMyDomain(property:'value').save() defresult=controller.get() assertresult==testInstance } }
  41. 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. 42. COMING SOON! Grails 2.3 -Spock byDefault! NewinGrails 2.3
  43. 43. YOU MAY FIND SURPRISES...
  44. 44. Note: if you do have test-pollution... Ted Naleid's Blog onFinding Test Pollution
  45. 45. TOUGHER / LESS DOCUMENTED GOTCHAS
  46. 46. PLUGIN DEPENDENCY DEFINITION
  47. 47. APPLICATION.PROPERTIES - > BUILDCONFIG.GROOVY
  48. 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. 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. 50. APPLICATION.PROPERTIES (AFTER) #GrailsMetadatafile #MonMar1813:56:54CDT2013 app.grails.version=2.1.0 app.name=patient-application app.servlet.version=2.4
  51. 51. RESOURCES PLUGIN
  52. 52. Bydefault, JS, CSS, images etc are now managed bythe resources plugin. <r:layoutResources> <r:require modules="jquery-ui, blueprint">
  53. 53. This can mean a*lot*of restructuringto your front-end file management.
  54. 54. STRUCTURED PROPERTIES
  55. 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. 56. Discoveringthe shadowycorners...
  57. 57. TRY DIGGING DEEPER...
  58. 58. AND DEEPER.....
  59. 59. BUT EVENTUALLY... in 1.3.7... the same???
  60. 60. FIX IT AND LET IT GO
  61. 61. TAKEAWAY POINTS
  62. 62. TAKE YOUR TIME
  63. 63. Tryto keep new feature developmentto aminimum
  64. 64. Do aback-merge allatonce, rightbefore finishing. Communicate with your team!
  65. 65. Take alook for existingdocs on how upgrade problems were solved...
  66. 66. ... butknow thatsome problems willbe unique to your codebase.
  67. 67. Don'tfear the source, love the source.
  68. 68. If allelse fails, ask the communityif you getstuck!
  69. 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. 70. SPECIAL THANKS TO: Zan Thrash Zach Legein Zach Lendon Colin Harrington SenthilKumaran Team @ virtuwell and Mywife, Virginia
  71. 71. THANKS FOR LISTENING! Anyquestions? Givemefeedback! http://tinyurl.com/gr8wbuck13 Myinfo(again) Twitter(@wbucksoft) Github(willbuck) Email(wbucksoft@gmail.com)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×