Friday, 30 July 2010

Grails one-liner package and install plugin

As we all know, running Grails with source plugins can cause a few oddities and many people prefer to run their plugins packaged. One bug I experienced on Grails 1.1 was uninstalling a source-linked plugin deleted the source code! Argh!

I was getting annoyed with having to have multiple terminal tabs open: one to package my plugin and another to install it, wait 3 seconds, type "y" and then to run my application. The command below solves my problems:


pushd ~/sites/plugin-a/; grails package-plugin; popd; yes | grails install-plugin ~/sites/plugin-a/grails-plugin-a-0.1.zip; grails clean; grails run-app



I pipe "yes" to grails-install plugin; otherwise you'll be prompted to type "y" or "yes".

You can also combine these if you need to package multiple plugins.



pushd ~/sites/plugin-a/; grails package-plugin; popd; yes | grails install-plugin ~/sites/plugin-a/grails-plugin-a-0.1.zip; pushd ~/sites/plugin-b/; grails package-plugin; popd; yes | grails install-plugin ~/sites/plugin-b/grails-plugin-b-0.1.zip; grails run-app


It gets a little unreadable but can certainly save a lot of waiting/repeated typing.

No comments: