SlideShare a Scribd company logo
1 of 71
Download to read offline
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)

More Related Content

What's hot

บทที่3
บทที่3บทที่3
บทที่3
Palm Unnop
 

What's hot (16)

Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
 
PostgreSQL: Joining 1 million tables
PostgreSQL: Joining 1 million tablesPostgreSQL: Joining 1 million tables
PostgreSQL: Joining 1 million tables
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
 
The Ring programming language version 1.8 book - Part 77 of 202
The Ring programming language version 1.8 book - Part 77 of 202The Ring programming language version 1.8 book - Part 77 of 202
The Ring programming language version 1.8 book - Part 77 of 202
 
The Ring programming language version 1.7 book - Part 75 of 196
The Ring programming language version 1.7 book - Part 75 of 196The Ring programming language version 1.7 book - Part 75 of 196
The Ring programming language version 1.7 book - Part 75 of 196
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecases
 
Sword fighting with Dagger GDG-NYC Jan 2016
 Sword fighting with Dagger GDG-NYC Jan 2016 Sword fighting with Dagger GDG-NYC Jan 2016
Sword fighting with Dagger GDG-NYC Jan 2016
 
GWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 PanicGWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 Panic
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
 
利用Init connect做mysql clients stat 用户审计
 利用Init connect做mysql clients stat 用户审计 利用Init connect做mysql clients stat 用户审计
利用Init connect做mysql clients stat 用户审计
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189
 
บทที่3
บทที่3บทที่3
บทที่3
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 

Similar to Upgrading Grails 1.x to 2

Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And Tricks
Mike Hugo
 
2009 03-26 grails-testing
2009 03-26 grails-testing2009 03-26 grails-testing
2009 03-26 grails-testing
geoffnettaglich
 
Groovygrailsnetbeans 12517452668498-phpapp03
Groovygrailsnetbeans 12517452668498-phpapp03Groovygrailsnetbeans 12517452668498-phpapp03
Groovygrailsnetbeans 12517452668498-phpapp03
Kevin Juma
 

Similar to Upgrading Grails 1.x to 2 (20)

Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013
 
Grails beginners workshop
Grails beginners workshopGrails beginners workshop
Grails beginners workshop
 
Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And Tricks
 
Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
Grails Advanced
Grails Advanced Grails Advanced
Grails Advanced
 
2009 03-26 grails-testing
2009 03-26 grails-testing2009 03-26 grails-testing
2009 03-26 grails-testing
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
 
Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!
 
Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016
 
AtlasCamp 2012 - Testing JIRA plugins smarter with TestKit
AtlasCamp 2012 - Testing JIRA plugins smarter with TestKitAtlasCamp 2012 - Testing JIRA plugins smarter with TestKit
AtlasCamp 2012 - Testing JIRA plugins smarter with TestKit
 
Play Framework vs Grails Smackdown - JavaOne 2013
Play Framework vs Grails Smackdown - JavaOne 2013Play Framework vs Grails Smackdown - JavaOne 2013
Play Framework vs Grails Smackdown - JavaOne 2013
 
Gradle how to's
Gradle how to'sGradle how to's
Gradle how to's
 
Groovygrailsnetbeans 12517452668498-phpapp03
Groovygrailsnetbeans 12517452668498-phpapp03Groovygrailsnetbeans 12517452668498-phpapp03
Groovygrailsnetbeans 12517452668498-phpapp03
 
Config/BuildConfig
Config/BuildConfigConfig/BuildConfig
Config/BuildConfig
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
 
Os Davis
Os DavisOs Davis
Os Davis
 
Grails 3.0 Preview
Grails 3.0 PreviewGrails 3.0 Preview
Grails 3.0 Preview
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
Droidcon Paris 2015
Droidcon Paris 2015Droidcon Paris 2015
Droidcon Paris 2015
 
Making the Most of Your Gradle Build
Making the Most of Your Gradle BuildMaking the Most of Your Gradle Build
Making the Most of Your Gradle Build
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Upgrading Grails 1.x to 2