Upgrading Grails 1.x to 2
Upcoming SlideShare
Loading in...5
×
 

Upgrading Grails 1.x to 2

on

  • 884 views

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

Statistics

Views

Total Views
884
Views on SlideShare
879
Embed Views
5

Actions

Likes
0
Downloads
6
Comments
0

2 Embeds 5

https://twitter.com 4
http://localhost 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Upgrading Grails 1.x to 2 Upgrading Grails 1.x to 2 Presentation Transcript

    • UPGRADING FROM GRAILS 1.X TO 2.X STORIES AND LESSONS LEARNED WillBuck,webdeveloper,virtuwell Twitter(@wbucksoft) Github(willbuck) Email(wbucksoft@gmail.com)
    • 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 internal) LOTS of testingoverhaul
    • 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 memoryGORM (makingunittestingcriteriaQueries possible) Better Console Output Cleaner testreports Annotation based mockingmakes code more straight-forward (imho)
    • 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.
    • 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!)
    • 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 cleaner -single commitof merge back!
    • 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(){ //NoneedtomockDomain()anymore,justsaveaway! MyDomaintestInstance=newMyDomain(property:'value').save() defresult=controller.get() assertresult==testInstance } }
    • 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 } }
    • 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-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
    • 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" }
    • APPLICATION.PROPERTIES (AFTER) #GrailsMetadatafile #MonMar1813:56:54CDT2013 app.grails.version=2.1.0 app.name=patient-application app.servlet.version=2.4
    • RESOURCES PLUGIN
    • Bydefault, JS, CSS, images etc are now managed bythe resources plugin. <r:layoutResources> <r:require modules="jquery-ui, blueprint">
    • 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 StringtelephoneNumber StringtelephoneNumber_areaCode StringtelephoneNumber_prefix StringtelephoneNumber_lineNumber //Accidentaloopsies,butwon'tkillthings Stringname Stringname_sourceId //NOWwe'retalkingtrouble DatedateOfBirth StringdateOfBirth_sourceId }
    • 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: 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
    • 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(willbuck) Email(wbucksoft@gmail.com)