////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

== create-script

=== Purpose

The `create-script` command creates a new Grails code generation script that can be run with the `grails` command from a terminal window.

=== Examples

The command:

[source,groovy]
----
grails create-script my-script
----

Creates a script called `src/main/scripts/my-script.groovy` such as:

[source,groovy]
----
description "Example description", "grails example-usage"

println "Example Script"
----

The command can then be run with:

[source,groovy]
----
grails my-script
----

=== Description

Each script extends from the super class link:{apiFromRef}org/grails/cli/profile/commands/script/GroovyScriptCommand.html[GroovyScriptCommand] which provides an API for achieving a number of different tasks.

=== Invoking Gradle

You can invoke Gradle using the `gradle` property:

[source,groovy]
----
gradle.assemble()
----

You can run any other Grails scripts by simply invoking the method:

[source,groovy]
----
testApp()
----

Code generation can be performed using the link:{apiFromRef}org/grails/cli/profile/commands/templates/TemplateRenderer.html[TemplateRenderer API]

For more information, see the section on link:{guidePath}commandLine.html#creatingCustomScripts[creating custom scripts].
