In Grails 2.1 (RC2 available at time of writing), Grails introduced a new “alias” command. Like the rest of Grails, there is good high-level documentation for this command. However, here are a few more details.
You can use aliases to shorten long grails commands. For example, instead of typing this long command every time:
grails test-app integration:spock
You could create an alias one time like this (tis = “test integration spock”):
grails alias tis test-app integration:spock
And then just use the “tis” alias:
Check out the documentation for details on how to list (grails alias –list) and delete (grails alias –delete=tis) aliases.
The biggest disappointment was that you can’t use ‘-’ or ‘–’ switches/parameters. So I cannot do something like:
DOES NOT WORK grails alias tis test-app integration:spock -coverage
Any command-line switches like “-coverage” are applied to the alias command. However, you could do this with the original “tis” which is better than nothing:
grails tis -coverage
Under the Covers
If interested, there is a file in called <grails_home>/.aliases that contains the list of aliases. This master list applies to all grails projects and all versions of grails. However, you cannot run the alias command outside of a grails project, which I think is strange.
While this has potential to be useful, it is nothing that I can’t do already, and with more power, using “alias” on Mac/Linux or something like “doskey” on Windows. Since this is the first iteration, it will be interesting to see how this evolves.