Setting up a Cordova build environment with some Grunt

Using the task-based build tool   Grunt , the new  Cordova  command line tooling,  and  Jasmine  tests running in  PhantomJS  to build better apps

Who am I?

Tommy-Carlos Williams

tommy@devgeeks.org

@theRealDevgeeks

http://blog.devgeeks.org
http://github.com/devgeeks

Why?

  • Build automation
  • Continuous integration (Travis-CI, etc)
  • Test/behaviour driven development
  • Xcode, Eclipse and friends are painful
  • Multiple platforms, one code base
  • The command line is powerful
  • There are many great Grunt plugins

Requirements


Just 9 easy* steps!

  1. Install the 4 primary dependencies
  2. Create a Cordova project
  3. Add your Cordova platforms (iOS, Android, etc)
  4. Create a package.json  file
  5. Install the 3 grunt plugin npm modules using --save-deps
  6. Initialise Grunt and create a grunt.js file
  7. Hand edit the  grunt.js  file and edit your src paths
  8. Hand edit the  grunt.js  file and add your Jasmine tasks
  9. Hand edit the  grunt.js  file and add your Cordova shell tasks

* Easy is a relative term... are you scared of hand editing config files?  Hope not.


The steps were so complex I didn't even want to write them up


:*(


Much less try to describe it in a talk...

Luckily, you can write custom Grunt scaffolding templates...

   

...or even better get someone else to write it for you:


https://github.com/devgeeks/grunt-init-cordova

Now it's just 6 actually easy steps*

  1. Install the 4 primary dependencies
  2. Install the grunt-init-cordova templates
  3. Create a Cordova project
  4. Add your Cordova platforms (iOS, Android, etc)
  5. Initialise Grunt with the templates above (answering a couple of easy questions)
  6. Run npm install  to install all dependencies

THAT'S IT! WE ARE READY TO ROLL!

* The first step still sucks...

Demo

Optional Next steps


  • Pick a UI framework
  • Decide on a MVC framework
  • Choose or build a backend
  • Actually build your app!

 Thanks


Feel free to ask me any PhoneGap / Cordova questions you may have as long as they have nothing to do with jQuery Mobile.

Just kidding. *
  
          
* I'm totally not kidding.