The project in question is built in Grails but uses Bower to ensure we have the right versions of AngularJS, Bootstrap, etc. Once your development machine is setup it’s as “easy” as running bower install whenever the dependencies change, and otherwise using the standard grails commands.

When you come to a fresh machine there are a few more steps before you can get up and running:

Have I got Grails installed?

Have I got NodeJS installed?

Have I installed Bower using NPM?

Have I run Bower to install the dependencies?

This is already too much hassle! Grails makes life easier by generating a Grails wrapper, grailsw, so we don’t need to check that Grails is installed. So far, so good!

NodeJS is a requirement for development, so I made the assumption that any developer machine would have it present. From there I wanted to use NPM to install Bower and then run Bower to grab the dependencies. There were plenty of options but I’m keen to learn a bit more Gradle so this was a great opportunity. 15 minutes later and we’ve got a build file (thanks to Mr Haki for the OutputStream processing):

There may well be a better way of doing this, but it worked for me on OSX. There was a path-related error when we tried to run it on Windows, and if anyone can point out why that would be great.

Once the Gradle build has completed you still need to run grailsw run-app but 2 steps is better than 4. A brief foray into building Grails with Gradle yielded spurious errors before my 15 minutes was up, but recent commits may well solve that. Grails is expected to move to Gradle for version 3, so soon we’ll be able to do our entire build process through a single click.

Discuss!

Was this post useful? Why not help others find it by sharing on twitter. While you're there, get in touch and let me know what you think!