"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Command Line/run-script.html" (14 Sep 2022, 59950 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)
run-script
Purpose

Execute Groovy script(s) in the context of a Grails environment.

Groovy scripts intended to be executed this way cannot be located in src/main/scripts because that directory is reserved for CLI scripts created by create-script.
Examples
// run a single script in the dev environment
grails run-script scripts/helloWorld.groovy

// run multiple scripts in the prod environment
grails prod run-script scripts/hello.groovy scripts/world.groovy

// run with Gradle
./gradlew runScript -Pargs="scripts/helloWorld.groovy" -Dgrails.env=prod

The paths are resolved relative to the base project path

Description

Usage:

grails <<env>>* run-script <<scripts>>

Arguments:

  • scripts - Which scripts to run

Variables:

The ctx variable is injected into all scripts and is an instance of the ApplicationContext

Scripts are executed in the context of a persistent session. The default package is imported by default (grails.codegen.defaultPackage)