My "Perfect" Toolchain Setup for Grails Projects


Published on

Presentationslides from the GR8Conf presentation. Find the abstract here:

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

My "Perfect" Toolchain Setup for Grails Projects

  1. 1. My "Perfect" ToolchainSetup for Grails Projects Stefan Armbruster netjay GmbH & Co. KG
  2. 2. about me● located in Munich/Germany● freelancer since +10 years● cofounder of Netjay● Java +10 years, Groovy ~5 years, Grails 3+ years● +3 years Neo4j experience, involved in the community● author of some Grails plugins and Neo4j-Grails integration plugin● passionate volunteer firefighter● @darthvader42●
  3. 3. Were hiring
  4. 4. Compare developing a Grails application with cooking
  5. 5. Tools youll needSoftware engineering process●Ticketing system●Editor / IDE●Version control / branching model●continuous integration●Automated deployments●Load testing / Profiling●
  6. 6. Education scienceOnly hear 20 %Only see 30 %See and hear 50 %See, hear and discuss 70 %See, hear, discuss and 90%do-it-yourself
  7. 7. About this workshopLets create a small application●Setup all tooling●Deliver today !●For server side tools:● – Ubuntu 12.04 image as VM image – Login: dev / 12345dev!Developers laptop:● – JDK, Grails, Virtualbox, IntelliJ, git
  8. 8. Introducing demo project: gr8shopSmall shopping application●Simple use-cases● ● As a shopmanager I want to CRUD my products so the customers can buy something ● As a customer I want to put products in my shopping cart to buy them ● As a customer I want my shopping cart to be persistent so I can access it at a later timepoint
  9. 9. Choose a processScrum●Waterfall●RUP●Many more available●Combined with Kanban ?●None ;-)●
  10. 10. Stefans lessons learned● Team agreement on a DoD „defintion of done“: – Tested (unit, functional, ...) – Peer review – Documentation (how and where?)● Dont omit the physical taskboard● Do pair programming – on important things – If team skills differ● If youre not familiar with scrum, hire a good coach!● On start, get management committment and remember them
  11. 11. Ticketing systems / backlog toolSingle location for user stories●Support for non-local teammebers●Well look at:● – JIRA ( • Only available during workshop +2 weeks – Redmine • Well install that in the dev server vm
  12. 12. Atlassian JIRA + Greenhopper● Most powerful issue tracking system● Lots of plugins, great IDE integration● Widely used (e.g. Grails itself uses Jira)● Not free for commercial use● Download as war or hosted product („Studio“)●● Our demo instance: – admin / gr8admin – dev / gr8dev – po / gr8po
  13. 13. RedmineRoR based●Issues, wiki, news, documents, forum ....●SCM integration, lots of plugins●Debian/Ubuntu packages available● sudo apt­get install redmine redmine­sqlite libapache2­ mod­passenger Apache: copy contents of /usr/share/doc/redmine/examples/apache2­passenger­ host.conf to /etc/apache2/sites­available/defaultAccess: http://<server>, user:admin, pw:admin●
  14. 14. IDE matrix - YMMVName Pros ConsIntelliJ •IDE with a strong focus on java •You have to pay when used development commercially •„knows what you want to do“ •Learning curve •most advanced support for Grails •Task integration (IMHO)SpringSource •Eclipse is widely adopted More a set of plugins instead of a •Eclipse STS •backed by SpringSource well integrated monolith •free •rich Plugin ecosystemNetbeans ? ?Textmate A lot of „gurus“ use it Mac onlyvi(m), emacs •Everywhere available •Not the easiest thing to learn •Uses very few resources •Poor code assist •Only real programmers use viSublime ? ?
  15. 15. Hints for IntelliJ● Use the same codestyle settings for your team – esp. line seperator setting● Learn keybindings, use „key promoter“ plugin● When using Jira use Atlassian connector● Some of my favourites: – Ctrl+W: semantic highlighting – Shelve/Unshelve – Run units test for Grails directly – Debugger – Zen coding support
  16. 16. SCM overviewYou have the choie: – The old ones: diff/patch, RCS, CVS – The most used (currently): SVN – The hip ones: GIT, hg, bazaar, ... (DVCSs) – The PITAs: Perforce, M$ Sourcesafe, ...Online repo providers: – Github, Bitbucket, Sourcforge, etc.
  17. 17. GIT: overview (kudos to @struberg)GIT works similar to patch based systems●GIT is de-centralised: all changes are also available● offlineGIT is distributed: changes can be pulled/pushed● from/to remote repositoriesAll patches are available locally●Commits are cryptographically strong●
  18. 18. GIT concepts – object tree● GIT always tracks the whole repository● GIT tracks a tree containing diffs with their parents and commit information● .git/objects contains all those commits● each commit has a unique sha1 containing the diff-object plus● tree information, and further● each commit has a unique sha1 containing the tree-object + commit info● git packs objects space optimized
  19. 19. GIT commit tree
  20. 20. ● GIT doesnt work directly against the Repository but has a preparation area called Index● all changes prepared in that Index will only get stored to the Repositories tree-objects with the commit upstream repo1 I N file D local change E repo X upstream repo2
  21. 21. GIT documentation / toolsDocs: – Interactive cheatsheet – – – Command line, gitk, giggle – IDE (IntelliJ, STS, netbeans) – Mac: git-tower – SmartGit (free for non-commercial)
  22. 22. git flow:a branching modelApplys a practical proven branching model on top of gitdevelop: permanent branch, current developmentmaster: permantent branch, holds stable releasesrelease: temporary branch for stabilizing/hardening prereleasehotfix: temporary branch for bugfixing
  23. 23. git flow - setupwget ­q – low­ –no­check­certificatesudo chmod a+x gitflow­; sudo ./gitflow­ installer.shUsage: cd <repo>; git flow init (use once) git flow feature [start|publish|finish|pull|list] git flow release [start|publish|finish] git flow hotfix [start|finish]
  24. 24. GIT tipsChoose .gitignore carefully:● – – Consider adding IDE control files ?Team agreement on commit messages● – e.g. „refs/closes #<id>: [NEW|FIX|CON|ETF] <msg>“Rebase is powerful, but do not rebase pushed stuff!●
  25. 25. Remote repo manager: gitoliteGIT by itself has no security or authentication●Gitolite uses ssh for this●apt­get install gitolite, provide admin key●Clone admin repo:● – git clone gitolite@<hostname>:gitolite­admin.git – Add public ssh keys to keys/ – Setup project in conf/gitolite.conf – Commit & push
  26. 26. Publish gr8shopConnect local repo to remote (only once)● – git remote add origin  gitolite@<hostname>:gr8shop.gitgit push –all●Other team mates:● – git clone  gitolite@<hostname>:gr8shop.git
  27. 27. Setup CI: Jenkinsapt-get install jenkins-tomcat● – http://<hostname>:8080/jenkinsInstall some plugins:● – Chuck Norris (you cant live without it!) – Grails (obvious) – Git – Violations – Maven – Deploy
  28. 28. JenkinsConfigure multiple small dependent jobs instead of 1 huge job● – Faster response when something goes wrongLet git postreceive hook trigger jenkins instead of jenkins querying git● every x minutes – Jenkins must be security enabled – Use external trigger in jobs config – Postreceive hook for git: curl "http://admin:admin@localhost:8080/jenkins/job/gr8shop_unittests/build? token=abc"Parameterize deploy job with a git refspec●
  29. 29. Functional testsKiller combo for testing: Spock + Geb●Demoing...●For running Geb tests on Jenkins: either use:● – RemoteWebDriver, – HtmlUnit driver, or – [Firefox,Chrome] + Xvnc plugin, see • browser-tests-jenkins/
  30. 30. Code qualityUse codenarc plugin●Apply to grails-app/conf:● codenarc {     reportName = target/test­reports/CodeNarcReport.xml     reportType = xml     propertiesFile = grails­app/conf/ }And Jenkins violation plugin:● – „Report violations, codenarc“: target/test-reports/CodeNarcReport.xml
  31. 31. LoadtestingDemoing jmeter....Alternatives: – Grinder – HP LoadRunner (if you have too much $$$)
  32. 32. ProfilingDemoing Yourkit ProfilerAlternatives – JVisualVM – JDKs command line tools (jmap/jhat/jstat/jstack) – Netbeans Profiler
  33. 33. Need to modify existing plugin?Fork the plugin on github●Use git submodule to nest the fork in your project●Inline the plugin●Think of contributing your plugin changes!●My blog post for this:●
  34. 34. Kudos / referencesBoris Glogers scrum checklist:●●●●●●●