// 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
run-script
目的
在 Grails 環境的背景下執行 Groovy 腳本。
預計以這種方式執行的 Groovy 腳本不能位於 src/main/scripts ,因為該目錄是保留給 create-script 建立的 CLI 腳本。
|
範例
路徑相對於基礎專案路徑解析
說明
用法
grails <<env>>* run-script <<scripts>>
引數
-
scripts
- 要執行的腳本
變數
ctx
變數會注入到所有腳本中,而且是 ApplicationContext
的執行個體
腳本會在持續性工作階段的背景下執行。預設套件會預設匯入 (grails.codegen.defaultPackage )
|