12.6 Hooking into Build Events - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith
Version: null
12.6 Hooking into Build Events
Post-Install Configuration and Participating in Upgrades
Configuración en la Post-instalación y participación en los upgrades
Grails plugins can do post-install configuration and participate in application upgrade process (the upgrade command). This is achieved using two specially named scripts under the
Los plugins de grails pueden hacer configuración en la post-instalación y participar en el proceso de upgrade de una aplicación (el comando upgrade). Esto se realiza usando dos scripts con nombres especiales en la carpeta scripts directory of the plugin - _Install.groovy and _Upgrade.groovy._Install.groovy is executed after the plugin has been installed and _Upgrade.groovy is executed each time the user upgrades the application (but not the plugin) with upgrade command.These scripts are Gant scripts, so you can use the full power of Gant. An addition to the standard Gant variables there is also a pluginBasedir variable which points at the plugin installation basedir.As an example this _Install.groovy script will create a new directory type under the grails-app directory and install a configuration template:
scripts del plugin - _Install.groovy y _Upgrade.groovy.El script _Install.groovy es ejecutado despues de quue el plugin haya sido instalado y el script _Upgrade.groovy es ejecutado cada vez que el usuario haga un upgrade de la aplicación (pero no del plugin) con el comando upgrade.Estos scripts son scripts de Gant, por lo que se tiene a disposición toda la potencia e Gant. Además de las variables estandar de Gant, dentro del script esta disponible también una variable pluginBasedir que apunta al directorio base de instalación del plugin.Como ejemplo, este script _Install.groovy creará un nuevo tipo de directorio dentro del directorio grails-app e instalará una plantilla de configuración.
ant.mkdir(dir: "${basedir}/grails-app/jobs")ant.copy(file: "${pluginBasedir}/src/samples/SamplePluginConfig.groovy", todir: "${basedir}/grails-app/conf")
Scripting events
It is also possible to hook into command line scripting events. These are events triggered during execution of Grails target and plugin scripts.For example, you can hook into status update output (i.e. "Tests passed", "Server running") and the creation of files or artefacts.A plugin just has to provide an_Events.groovy script to listen to the required events. Refer the documentation on Hooking into Events for further information.
Ejecutando scripts en eventos
Es posible inyectar acciones durante los eventos que se produce al lanzar scripts en la linea de comandos. Estos son eventos lanzados durante la ejecución de targets de Grais y scripts de plugins.Por ejemplo, es posible inyectar en la salida de updateo de estado (i.e. "Test passed", "Server running") y en la creación de ficheros o artefactos.Un plugin solo necesita un script_Events.groovy para ser notificado de los eventos que necesite. Para más información visitar la página Hooking into Events

