Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix run-script docs to prevent confusion with src/main/scripts
  • Loading branch information
jameskleeh committed Jul 21, 2016
1 parent b71721c commit 468f465
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/en/ref/Command Line/run-script.gdoc
Expand Up @@ -2,24 +2,30 @@ h1. run-script

h2. Purpose

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

{warning}
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|commandLine].
{warning}

h2. Examples

{code:java}
// run a single script in the dev environment
grails run-script src/main/scripts/helloWorld.groovy
grails run-script scripts/helloWorld.groovy

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

// run a single script in the dev environment and don't run Bootstrap
grails run-script src/main/scripts/helloWorld.groovy
grails run-script scripts/helloWorld.groovy

// run with Gradle
./gradlew runScript -Pargs="src/main/scripts/helloWorld.groovy" -Dgrails.env=prod
./gradlew runScript -Pargs="scripts/helloWorld.groovy" -Dgrails.env=prod
{code}

The paths are resolved relative to the base project path

h2. Description

Usage:
Expand All @@ -36,9 +42,5 @@ Variables:
The @ctx@ variable is injected into all scripts and is an instance of the @ApplicationContext@

{note}
Scripts are executed in the context of a persistent session
{note}

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

0 comments on commit 468f465

Please sign in to comment.