When working on a Grails project, I generally prefer using text editors over heavyweight IDEs. They seem to give me more flexibility and agility than their bulky counterparts. For Groovy and Grails in particular, I favour using the great Gnome text editor gedit.
Using this editor by itself does come with limitations since it knows nothing about Grails. Next, you can give it wings by installing additional helper files found in the gedit-grails-bundle. This will add Groovy syntax highlighting, bundles, and many other nice features like tab completion for the grails command on the command line. After this has been installed, and all instructions have been followed, gedit should be fully functional and ready to work on your Grails project. It should function much like TextMate on Mac OS X.
I began to realize that despite all of this, one thing was missing: I wanted to invoke gedit from the command line like I invoke the grails script. Wouldn’t it be great if you had a script to do this? In steps gred! It is my attempt at doing just this. It is a script that can be placed on your path, helping you to get to your files fast!
If you have Git installed, get it off github like this:
git clone git://github.com/marcoVermeulen/scripts.git
As super user, place the script in the gred folder on your path, and make it
executable:
$ cp scripts/gred/gred /usr/local/bin/
$ chmod +x /usr/local/bin/gred
In order to use the script, ensure that you have the following line in your
~/.bashrc file:
export EDITOR="/usr/bin/gedit"
Also ensure that you already have gedit running before running gred the first time.
Now change to the directory of your project:
cd myproject
By simply entering the command, you will receive the following help:
Usage: gred [option]
options:
-tests : open all unit and itegration tests.
-unit : open unit tests
-integration : open integration tests
-int : open integration tests
-builder : open test object builders
-controller : open controller
-service : open all services
-views : open all .gsp files for domain class
An example of using this script: Having a User domain class with unit and integration tests in your Grails project, you can open gedit on all the related artifacts by simply typing:
> gred user -all
If you only wanted to see the integration test, you could type:
> gred user -integration
or simply
> gred user -int
It is also noteworthy that the name of the domain class can be written in a case-insensitive way for convenience.
If you have any suggestions of how you would like the script improved, please drop me a comment. Thanks for reading, and hope you enjoy the script! Cheers, Marco.