grails-run-script /

Filename Size Date modified Message
766 B
42 B
500 B
832 B
191 B


This is a quick and dirty script that allows the running of a groovy script within the grails context. This means that the script has access to the hibernate session and that your GORM domain classes are hooked up (as well as any other plugins that you might have installed).

If you're able to execute the script within a "grails console" you should be able to use run-script to execute it from the command line.


grails run-script path-to-script/scriptName.groovy

Example (included in this sample grails app):

grails run-script userScripts/createBook.groovy

If you take a look at that script, you'll see that it creates and Author and some Books and saves them to the database. It then asserts that they are there. This shows the interaction with the database as well as the domain objects.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.