Archive for the ‘scripts’ Category

Updated bash completion script for OSX and Grails 1.1 & 1.2

January 6th, 2010 5 comments

Fernando Takai wrote an excellent bash completion script (also available here, originally from Ted Naleid), which makes calling Grails commands much easier.

Some examples:

Within a Grails application directory, listing all available commands:

myapp> grails [tab][tab]
bootstrap create-integration-test generate-controller list-plugins_ set-version
bug-report create-plugin_ generate-views package shell
clean create-script help_ package-plugin_ stats
compile create-service init plugin-info_ test-app
console create-tag-lib install-dependency release-plugin tomcat
create-app_ create-unit-test install-plugin run-app uninstall-plugin
create-controller dependency-report install-templates run-war upgrade
create-domain-class doc integrate-with schema-export war
create-filters generate-all list-plugin-updates set-proxy_

Within a Grails application directory, completing a command:

myapp> grails run-[tab][tab]
run-app run-war

Outside of a Grails application directory, listing all available commands:

home> grails [tab][tab]
create-app create-plugin help list-plugins package-plugin plugin-info set-proxy


I updated the script to adapt it to new Grails versions and made some minor changes:

* works with plugin provided scripts in Grails version >= 1.1, were plugins are stored under $HOME/.grails/grailsversion/projects/appname/plugins.
* detects the Grails version from $GRAILS_HOME instead of choosing the latest version from $HOME/.grails.
* adapts to different locations of plugins-list.xml, which changed with newer Grails versions
* does not need gawk (which is not installed by default on OSX)

My version of the script was tested with Grails 1.2 and OSX Snow Leopard and can be found at GitHub or below.


Save the script to an appropriate path (e.g. ~/bin/
[ -r ~/bin/ ] && source ~/bin/

The complete Script

Categories: grails, scripts Tags:

Script to inspect jar and war files, Grails applications and plugins

January 4th, 2010 Comments off

I just wrote a little script to inspect jar and war files, Grails applications and plugins.


Simply copy the script to somewhere in your path (e.g. ~/bin) and make it executable using
chmod +x jinspect

I tested the script on OSX Snow Leopard, but it should run on other versions of OSX and Linux, too.


List all files in a war/jar/zip:
jinspect -l myapp.war

Show contents of some files in a jar/war/zip:
jinspect myapp.war index.html another.txt

List gsp and jsp files in a war:
jinspect -JG myapp.war

Show contents of web.xml file in a war:
jinspect -w myapp.war

Extract and save web.xml file in a war:
jinspect -Xw myapp.war

Show contents of the Plugin class of a Grails plugin:
jinspect -P

Available options:

jinspect [-hHvxXoawmISMWjJrgGcCpPlLZZZ] jarfile [filename ...]
-h show help
-v be more verbose
-X save specified files (including path) to the current directory instead of printing them
-l list war contents; specify again to include more information
-x list xml files
-o list properties files
-c list class files
-j list java files
-J list jsp files
-S list js files
-g list groovy files
-G list gsp files
-H list html files
-C list css files
-I list image files
-L list files in lib directory
-M list files in META-INF directory
-W list files in WEB-INF directory
-a show WEB-INF/applicationContext.xml
-w show WEB-INF/web.xml
-r show WEB-INF/grails.xml
-p show plugin.xml
-P show *GrailsPlugin.groovy
-d show manifest headers in nicely formatted way; implies -m
-D display named manifest header; can be used multiple times, implies -m

(also available on GitHub)

Categories: grails, scripts Tags:
Fork me on GitHub