How do I make Grails execute shell commands just before creating war file?

258 Views Asked by At

Let's say I want to do git pull origin master just before preparing a war file.

1

There are 1 best solutions below

0
On BEST ANSWER

To do something before the war is packaged, use the "CreateWarStart" event, e.g. as described in this answer. To actually run the Git command, use can use Groovy's ability to execute commands as strings, e.g. 'git pull origin master'.execute() (see the docs here) or do it more programmatically with ProcessBuilder like you would in Java, and optionally wrapped in a shell script to abstract the details away from the web app code.