blob: 695beb5a332c958ce722f60f260f82ace3f5c5bc [file]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDoNotTrack", true]);
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '79']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
<title>5 The Command Line 6.2.3</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen, print" title="Style" charset="utf-8"/>
<link rel="stylesheet" href="../css/pdf.css" type="text/css" media="print" title="PDF" charset="utf-8"/>
<script type="text/javascript">
function addJsClass() {
var classes = document.body.className.split(" ");
classes.push("js");
document.body.className = classes.join(" ");
}
</script>
</head>
<body class="body" onload="addJsClass();">
<div id="navigation">
<div class="navTitle">
The Grails Framework
</div>
<div class="navLinks">
<ul>
<li>
<div id="nav-summary" onmouseover="toggleNavSummary(false)" onmouseout="toggleNavSummary(true)">
<a href="../guide/index.html" class="button">Table of contents</a>
<div id="nav-summary-childs" style="display:none;">
<div class="toc-item" style="margin-left:0"><a href="../guide/introduction.html"><strong>1</strong><span>Introduction</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/gettingStarted.html"><strong>2</strong><span>Getting Started</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/upgrading.html"><strong>3</strong><span>Upgrading from the previous versions</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/conf.html"><strong>4</strong><span>Configuration</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/commandLine.html"><strong>5</strong><span>The Command Line</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/profiles.html"><strong>6</strong><span>Application Profiles</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/GORM.html"><strong>7</strong><span>Object Relational Mapping (GORM)</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/theWebLayer.html"><strong>8</strong><span>The Web Layer</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/traits.html"><strong>9</strong><span>Traits</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/REST.html"><strong>10</strong><span>REST</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/async.html"><strong>11</strong><span>Asynchronous Programming</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/validation.html"><strong>12</strong><span>Validation</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/services.html"><strong>13</strong><span>The Service Layer</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/staticTypeCheckingAndCompilation.html"><strong>14</strong><span>Static Type Checking And Compilation</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/testing.html"><strong>15</strong><span>Testing</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/i18n.html"><strong>16</strong><span>Internationalization</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/security.html"><strong>17</strong><span>Security</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/plugins.html"><strong>18</strong><span>Plugins</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/spring.html"><strong>19</strong><span>Grails and Spring</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/scaffolding.html"><strong>20</strong><span>Scaffolding</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/deployment.html"><strong>21</strong><span>Deployment</span></a>
</div>
<div class="toc-item" style="margin-left:0"><a href="../guide/contributing.html"><strong>22</strong><span>Contributing to Grails</span></a>
</div>
</div>
</div>
</li>
<li class="separator selected">
<a id="ref-button" onclick="localToggle(); return false;" href="#">Quick Reference</a>
</li>
</ul>
</div>
</div>
<table id="colset" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="col1">
<div id="main" class="corner-all">
<div class="toc-item prev-left"><a href="../guide/conf.html">&lt;&lt; <strong>4</strong><span>Configuration</span></a></div>
<span id='toggle-col1' class="toggle">(<a href="#" onclick="localToggle(); return false;">Quick Reference</a>)</span>
<div class="toc-item next-right"><a href="../guide/profiles.html"><strong>6</strong><span>Application Profiles</span> >></a></div>
<div class="project">
<h1>5 The Command Line</h1>
<p><strong>Version:</strong> 6.2.3</p>
</div>
<div id="table-of-content">
<h2>Table of Contents</h2>
<div class="toc-item" style="margin-left:0px"><a href="#interactiveMode"><strong>5.1</strong><span>Interactive Mode</span></a>
</div>
<div class="toc-item" style="margin-left:0px"><a href="#creatingCustomScripts"><strong>5.2</strong><span>Creating Custom Scripts</span></a>
</div>
<div class="toc-item" style="margin-left:0px"><a href="#creatingCustomCommands"><strong>5.3</strong><span>Creating Custom Commands</span></a>
</div>
<div class="toc-item" style="margin-left:0px"><a href="#creatingProject"><strong>5.4</strong><span>Creating a Grails Project</span></a>
</div>
<div class="toc-item" style="margin-left:0px"><a href="#reusingGrailsScripts"><strong>5.5</strong><span>Re-using Grails scripts</span></a>
</div>
<div class="toc-item" style="margin-left:0px"><a href="#gradleBuild"><strong>5.6</strong><span>Building with Gradle</span></a>
</div>
<div class="toc-item" style="margin-left:10px"><a href="#gradleDependencies"><strong>5.6.1</strong><span>Defining Dependencies with Gradle</span></a>
</div>
<div class="toc-item" style="margin-left:10px"><a href="#gradleTasks"><strong>5.6.2</strong><span>Working with Gradle Tasks</span></a>
</div>
<div class="toc-item" style="margin-left:10px"><a href="#gradlePlugins"><strong>5.6.3</strong><span>Grails plugins for Gradle</span></a>
</div>
</div>
<a name="4. The Command Line"><!-- Legacy link --></a>
<h1 id="commandLine">5 The Command Line</h1>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>Grails 3.0&#8217;s command line system differs greatly from previous versions of Grails and features APIs for invoking Gradle for build related tasks, as well as performing code generation.</p>
</div>
<div class="paragraph">
<p>When you type:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails &lt;&lt;command name&gt;&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Grails searches the <a href="http://bintray.com/grails/profiles">profile repository</a> based on the profile of the current application. If the profile is for a web application then commands are read from the web profile and the base profile which it inherits from.</p>
</div>
<div class="paragraph">
<p>Since command behavior is profile specific the web profile may provide different behavior for the <code>run-app</code> command then say a profile for running batch applications.</p>
</div>
<div class="paragraph">
<p>When you type the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails run-app</code></pre>
</div>
</div>
<div class="paragraph">
<p>It will first search the application, and then the profile for commands:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>PROJECT_HOME/src/main/scripts/run-app.groovy</code></p>
</li>
<li>
<p><code><a href="#profile">[profile]</a>/commands/run-app.groovy</code></p>
</li>
<li>
<p><code><a href="#profile">[profile]</a>/commands/run-app.yml</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>To get a list of all commands and some help about the available commands type:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">grails help</code></pre>
</div>
</div>
<div class="paragraph">
<p>which outputs usage instructions and the list of commands Grails is aware of:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">grails &lt;&lt;environment&gt;&gt;* &lt;&lt;target&gt;&gt; &lt;&lt;arguments&gt;&gt;*'
| Examples:
$ grails dev run-app
$ grails create-app books
| Available Commands (type grails help 'command-name' for more info):
| Command Name Command Description
----------------------------------------------------------------------------------------------------
clean Cleans a Grails application's compiled sources
compile Compiles a Grails application
...</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Refer to the Command Line reference in the Quick Reference menu of the reference guide for more information about individual commands
</td>
</tr>
</table>
</div>
<div class="sect2">
<h3 id="_arguments">Arguments</h3>
<div class="paragraph">
<p>The <code>grails</code> command is a front to a <code>gradle</code> invocation, because of this there can be unexpected side-effects.
For example, when executing <code>grails -Dapp.foo=bar run-app</code> the <code>app.foo</code> system property won&#8217;t be available to your application. This is because <code>bootRun</code> in your <code>build.gradle</code> configures the system properties.
To make this work you can simply append all <code>System.properties</code> to <code>bootRun</code> in <code>build.gradle</code> like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">bootRun{
systemProperties <span class="predefined-type">System</span>.properties <span class="comment">// Please note not to use '=', because this will override all configured systemProperties. This will append them.</span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Or if you only want to pass through a limited set, you can prefix your system properties using an arbitrary prefix and configure <code>bootRun</code> like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">bootRun{
bootRun {
systemProperties <span class="predefined-type">System</span>.properties.inject([:]){acc,item-&gt; item.key.startsWith(<span class="string"><span class="delimiter">'</span><span class="content">boot.</span><span class="delimiter">'</span></span>)?acc &lt;&lt; [(item.key.substring(<span class="string"><span class="delimiter">'</span><span class="content">boot.</span><span class="delimiter">'</span></span>.length())):item.value]:acc }
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this example only system properties starting with <code>boot.</code> are passed through.</p>
</div>
<div class="paragraph">
<p>Application and JVM arguments should be specified in <code>bootRun</code> as well.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">bootRun{
bootRun {
jvmArgs(<span class="string"><span class="delimiter">'</span><span class="content">-Dspring.output.ansi.enabled=always</span><span class="delimiter">'</span></span>)
args(<span class="string"><span class="delimiter">'</span><span class="content">--app.foo=bar</span><span class="delimiter">'</span></span>,<span class="string"><span class="delimiter">'</span><span class="content">--app.bar=foo</span><span class="delimiter">'</span></span>) <span class="comment">// Override the `app.foo` and `app.bar` config options (`grailsApplication.config`)</span>
}
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_non_interactive_mode">non-interactive mode</h3>
<div class="paragraph">
<p>When you run a script manually and it prompts you for information, you can answer the questions and continue running the script. But when you run a script as part of an automated process, for example a continuous integration build server, there&#8217;s no way to "answer" the questions. So you can pass the <code>\--non-interactive</code> switch to the script command to tell Grails to accept the default answer for any questions, for example whether to install a missing plugin.</p>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails war --non-interactive</code></pre>
</div>
</div>
<div class="paragraph">
<p>The Grails Forge New Command-Line Interface (CLI) has undergone significant changes compared to its previous versions, primarily focusing on code generation. One notable alteration is the removal of APIs for invoking Gradle for tasks related to building using Gradle Tooling APIs. This shift in responsibility aligns with the framework&#8217;s evolution and its integration with the Gradle build system.</p>
</div>
</div>
<div class="sect2">
<h3 id="_accessing_the_grails_cli">Accessing the Grails CLI</h3>
<div class="paragraph">
<p>The Grails CLI (Command Line Interface) can be swiftly and effortlessly accessed by simply typing the following command into your terminal or command prompt:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails</code></pre>
</div>
</div>
<div class="paragraph">
<p>This command allows developers to quickly initiate the Grails CLI and begin working with the framework, making it an easy entry point for those looking to start their Grails projects.</p>
</div>
<div class="paragraph">
<p>The New Grails CLI! is the preferred method for initiating new Grails projects. This command-line interface offers various options for creating projects, enabling you to select your preferred build tools, test frameworks, GORM implementation, and more. Additionally, the CLI provides commands for generating essential components like controllers and domain classes.</p>
</div>
</div>
<div class="sect2">
<h3 id="_the_grails_forge_website">The Grails Forge Website</h3>
<div class="paragraph">
<p>You can also begin your Grails application without the need to install the Grails CLI by visiting <a href="https://start.grails.org/">the Grails Forge website</a>. This web-based platform allows you to initiate Grails projects conveniently, bypassing the installation of the CLI.</p>
</div>
</div>
<div class="sect2">
<h3 id="_understanding_the_new_grails_command_line_interface_cli">Understanding the New Grails Command-line Interface (CLI)</h3>
<div class="paragraph">
<p>Once the Grails CLI has been successfully installed, you can activate it using the "grails" command. For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-app myapp</code></pre>
</div>
</div>
<div class="paragraph">
<p>A Grails framework CLI project is recognizable by the presence of the "grails-cli.yml" file, which is automatically generated at the project&#8217;s root if it was created using the CLI. This file contains information about the project&#8217;s profile, default package, and other variables.</p>
</div>
<div class="paragraph">
<p>Here is an example of a "grails-cli.yml" configuration for a default Grails web application:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="yaml"><span class="key">applicationType</span>: <span class="string"><span class="content">web</span></span>
<span class="key">defaultPackage</span>: <span class="string"><span class="content">com.example</span></span>
<span class="key">testFramework</span>: <span class="string"><span class="content">spock</span></span>
<span class="key">sourceLanguage</span>: <span class="string"><span class="content">groovy</span></span>
<span class="key">buildTool</span>: <span class="string"><span class="content">gradle</span></span>
<span class="key">gormImpl</span>: <span class="string"><span class="content">gorm-hibernate5</span></span>
<span class="key">servletImpl</span>: <span class="string"><span class="content">spring-boot-starter-tomcat</span></span>
<span class="key">features</span>:
- <span class="string"><span class="content">app-name</span></span>
- <span class="string"><span class="content">asset-pipeline-grails</span></span>
- <span class="string"><span class="content">base</span></span>
- <span class="string"><span class="content">geb</span></span>
- <span class="string"><span class="content">gorm-hibernate5</span></span>
- <span class="string"><span class="content">gradle</span></span>
- <span class="string"><span class="content">grails-application</span></span>
- <span class="string"><span class="content">grails-console</span></span>
- <span class="string"><span class="content">grails-dependencies</span></span>
- <span class="string"><span class="content">grails-gorm-testing-support</span></span>
- <span class="string"><span class="content">grails-gradle-plugin</span></span>
- <span class="string"><span class="content">grails-gsp</span></span>
- <span class="string"><span class="content">grails-url-mappings</span></span>
- <span class="string"><span class="content">grails-web</span></span>
- <span class="string"><span class="content">grails-web-testing-support</span></span>
- <span class="string"><span class="content">h2</span></span>
- <span class="string"><span class="content">logback</span></span>
- <span class="string"><span class="content">micronaut-inject-groovy</span></span>
- <span class="string"><span class="content">readme</span></span>
- <span class="string"><span class="content">scaffolding</span></span>
- <span class="string"><span class="content">spock</span></span>
- <span class="string"><span class="content">spring-boot-autoconfigure</span></span>
- <span class="string"><span class="content">spring-boot-starter</span></span>
- <span class="string"><span class="content">spring-boot-starter-tomcat</span></span>
- <span class="string"><span class="content">yaml</span></span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This "grails-cli.yml" configuration sets the default values for various aspects of the Grails web application, including the application type, default package, test framework, source language, build tool, GORM implementation, servlet implementation, and a list of enabled features.</p>
</div>
</div>
<div class="sect2">
<h3 id="_grails_default_package_configuration">Grails Default Package Configuration</h3>
<div class="paragraph">
<p>The project&#8217;s default package is determined based on the project&#8217;s name. For instance, running the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-app myapp</code></pre>
</div>
</div>
<div class="paragraph">
<p>Will set the default package to <code>myapp</code>.</p>
</div>
<div class="paragraph">
<p>If you wish to specify your own default package when creating the application, you can do so by prefixing the application name with the package like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-app com.example.myapp</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this case, "com.example" becomes the default package for your project.</p>
</div>
</div>
<div class="sect2">
<h3 id="_gradle_build_tool">Gradle Build Tool</h3>
<div class="paragraph">
<p>Grails now utilizes the Gradle Build System for project management. The project&#8217;s build configuration is specified in the <code>build.gradle</code> file, where you define critical aspects of your project such as its version, required dependencies, and the repositories from which these dependencies should be sourced. Here&#8217;s an example of how this is done:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">plugins {
id <span class="string"><span class="delimiter">'</span><span class="content">org.grails.grails-web</span><span class="delimiter">'</span></span> version <span class="string"><span class="delimiter">'</span><span class="content">x.y.z</span><span class="delimiter">'</span></span> <span class="comment">// Grails plugin</span>
}
repositories {
mavenCentral()
}
dependencies {
implementation <span class="string"><span class="delimiter">'</span><span class="content">org.springframework.boot:spring-boot-starter</span><span class="delimiter">'</span></span>
implementation <span class="string"><span class="delimiter">'</span><span class="content">org.grails:grails-core</span><span class="delimiter">'</span></span>
<span class="comment">// Add more dependencies as needed...</span>
}
grails {
pathingJar = <span class="predefined-constant">true</span>
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_utilizing_gradle_build_tool">Utilizing Gradle Build Tool</h3>
<div class="paragraph">
<p>To interact with your Grails project and perform various tasks related to building and running it, you should employ Gradle commands. Here are a few examples:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Building the Grails application:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">gradle build</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Running the Grails application:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">gradle bootRun</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Listing available Gradle tasks:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">gradle tasks</code></pre>
</div>
</div>
<div class="paragraph">
<p>By invoking these Gradle commands, you can effectively manage your Grails application&#8217;s lifecycle.</p>
</div>
<div class="paragraph">
<p>It is important to remember that Grails leverages the power of Gradle for streamlined project management, including build automation and dependency resolution. This approach allows for greater flexibility and control over your Grails projects.</p>
</div>
</div>
<h2 id="interactiveMode">5.1 Interactive Mode</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/interactiveMode.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>Interactive mode is a feature of the Grails command line which keeps the JVM running and allows for quicker execution of commands. To activate interactive mode type 'grails' at the command line and then use TAB completion to get a list of commands:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../img/interactive-output.png" alt="interactive output">
</div>
</div>
<div class="paragraph">
<p>If you need to open a file whilst within interactive mode you can use the <code>open</code> command which will TAB complete file paths:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../img/interactive-open-cmd.png" alt="interactive open cmd">
</div>
</div>
<div class="paragraph">
<p>Even better, the <code>open</code> command understands the logical aliases 'test-report' and 'dep-report', which will open the most recent test and dependency reports respectively. In other words, to open the test report in a browser simply execute <code>open test-report</code>. You can even open multiple files at once: <code>open test-report test/unit/MyTests.groovy</code> will open the HTML test report in your browser and the <code>MyTests.groovy</code> source file in your text editor.</p>
</div>
<div class="paragraph">
<p>TAB completion also works for class names after the <code>create-*</code> commands:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../img/interactive-complete-class.png" alt="interactive complete class">
</div>
</div>
<div class="paragraph">
<p>If you need to run an external process whilst interactive mode is running you can do so by starting the command with a !:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../img/interactive-run-external.png" alt="interactive run external">
</div>
</div>
<div class="paragraph">
<p>Note that with ! (bang) commands, you get file path auto completion - ideal for external commands that operate on the file system such as 'ls', 'cat', 'git', etc.</p>
</div>
<div class="paragraph">
<p>To exit interactive mode enter the <code>exit</code> command. Note that if the Grails application has been run with <code>run-app</code> normally it will terminate when the interactive mode console exits because the JVM will be terminated. An exception to this would be if the application were running in forked mode which means the application is running in a different JVM. In that case the application will be left running after the interactive mode console terminates. If you want to exit interactive mode and stop an application that is running in forked mode, use the <code>quit</code> command. The <code>quit</code> command will stop the running application and then close interactive mode.</p>
</div>
<div class="paragraph">
<p>With Grails Forge, when you execute the <code>grails</code> command without any arguments, the Grails Command Line Interface (CLI) enters interactive mode. In this mode, it functions like a shell, allowing you to run multiple CLI commands without the need to re-initialize the CLI runtime. This mode is particularly useful when working with code-generation commands (such as <code>create-controller</code>), creating multiple projects, or exploring various CLI features.</p>
</div>
<div class="paragraph">
<p>One of the advantages of interactive mode is the availability of tab-completion. You can simply press the TAB key to view possible options for a given command or flag. Here&#8217;s an example of the available options in interactive mode:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails&gt;
--help --verbose -V -v create-app create-domain-class create-restapi create-webapp
--stacktrace --version -h -x create-controller create-plugin create-web-plugin</code></pre>
</div>
</div>
<div class="sect1">
<h2 id="_help_and_information">Help and Information</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can access general usage information for Grails commands using the help flag associated with a specific command.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails&gt; create-app -h
Usage: grails create-app [-hivVx] [--list-features] [-g=GORM Implementation] [--jdk=&lt;javaVersion&gt;]
[-s=Servlet Implementation] [-t=TEST] [-f=FEATURE[,FEATURE...]]... [NAME]
Creates an application
[NAME] The name of the application to create.
-f, --features=FEATURE[,FEATURE...]
The features to use. Possible values: h2, scaffolding, gorm-hibernate5,
spring-boot-starter-jetty, springloaded, spring-boot-starter-tomcat,
micronaut-http-client, cache-ehcache, hibernate-validator, postgres,
mysql, cache, database-migration, grails-gsp, hamcrest, gorm-mongodb,
assertj, mockito, spring-boot-starter-undertow, micronaut-inject-groovy,
github-workflow-java-ci, jrebel, testcontainers, sqlserver,
grails-console, views-markup, asset-pipeline-grails, views-json,
gorm-neo4j, asciidoctor, embedded-mongodb, grails-web-console,
logbackGroovy, mongo-sync, shade, geb, properties
-g, --gorm=GORM Implementation
Which GORM Implementation to configure. Possible values: hibernate,
mongodb, neo4j.
-h, --help Show this help message and exit.
-i, --inplace Create a service using the current directory
--jdk, --java-version=&lt;javaVersion&gt;
The JDK version the project should target
--list-features Output the available features and their descriptions
-s, --servlet=Servlet Implementation
Which Servlet Implementation to configure. Possible values: none, tomcat,
jetty, undertow.
-t, --test=TEST Which test framework to use. Possible values: junit, spock.
-v, --verbose Create verbose output.
-V, --version Print version information and exit.
-x, --stacktrace Show full stack trace when exceptions occur.</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can also obtain a list of available features by using the --list-features flag with any of the create commands.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails&gt; create-app --list-features
Available Features
(+) denotes the feature is included by default
Name Description
---------------------------------- ---------------
CI/CD
github-workflow-java-ci [PREVIEW] Adds a Github Actions Workflow to Build and Test Grails Application
Cache
cache The Grails Cache plugin provides powerful and easy to use caching functionality to Grails applications and plugins.
cache-ehcache The Grails Cache Ehcache plugin extends the Cache plugin and uses Ehcache as the storage provider for cached content.
Client
micronaut-http-client Adds support for the Micronaut HTTP client
Configuration
properties Creates a properties configuration file
Database
database-migration Adds support for Liquibase database migrations. The Database Migration plugin helps you manage database changes while developing Grails applications.
embedded-mongodb Executes an embedded mongo database for integration or functional testing
gorm-hibernate5 (+) Adds support for Hibernate5 using GORM
gorm-mongodb Configures GORM for MongoDB for Groovy applications
gorm-neo4j Configures GORM for Neo4j for Groovy applications
h2 (+) Adds the H2 driver and default config
mongo-sync Adds support for the MongoDB Synchronous Driver
mysql Adds the MySQL driver and default config
postgres Adds the PostgresSQL driver and default config
sqlserver Adds the SQL Server driver and default config
testcontainers Use Testcontainers to run a database or other software in a Docker container for tests
Development Tools
assertj AssertJ fluent assertions framework
hamcrest Hamcrest matchers for JUnit
jrebel Adds support for class reloading with JRebel (requires separate JRebel installation)
springloaded Adds support for class reloading with Spring Loaded
Documentation
asciidoctor Adds support for creating Asciidoctor documentation
Logging
logbackGroovy Gives you the ability to use groovy to configure logback instead of XML.
Management
grails-web-console A web-based Groovy console for interactive runtime application management and debugging
Other
geb (+) This plugins configure Geb for Grails framework to write automation tests.
grails-console (+) Starts the Grails console, which is an extended version of the regular Groovy console.
micronaut-inject-groovy (+) micronaut-inject-groovy
scaffolding (+) The Grails® framework Scaffolding plugin replicates much of the functionality from Grails 2, but uses the fields plugin instead.
Packaging
shade Adds the ability to build a Fat/Shaded JAR
Server
spring-boot-starter-jetty spring-boot-starter-jetty
spring-boot-starter-tomcat (+) spring-boot-starter-tomcat
spring-boot-starter-undertow spring-boot-starter-undertow
Validation
hibernate-validator Adds support for the Hibernate Validator
mockito Mockito test mocking framework for JUnit
View Rendering
asset-pipeline-grails (+) The Asset-Pipeline is a plugin used for managing and processing static assets in JVM applications primarily via Gradle (however not mandatory). Read more at https://github.com/bertramdev/asset-pipeline
grails-gsp (+) grails-gsp
views-json JSON views are written in Groovy, end with the file extension gson and reside in the grails-app/views directory. They provide a DSL for producing output in the JSON format.
views-markup Markup views are written in Groovy, end with the file extension gml and reside in the grails-app/views directory. They provide a DSL for producing output in the XML.</code></pre>
</div>
</div>
</div>
</div>
<h2 id="creatingCustomScripts">5.2 Creating Custom Scripts</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/creatingCustomScripts.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>You can create your own Command scripts by running the <a href="../ref/Command%20Line/create-script.html">create-script</a> command from the root of your project. For example the following command will create a script called <code>src/main/scripts/hello-world.groovy</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails create-script hello-world</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
In general Grails scripts should be used for scripting the Gradle based build system and code generation. Scripts cannot load application classes and in fact should not since Gradle is required to construct the application classpath.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>See below for an example script that prints "Hello World":</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">description <span class="string"><span class="delimiter">&quot;</span><span class="content">Example description</span><span class="delimiter">&quot;</span></span>, <span class="string"><span class="delimiter">&quot;</span><span class="content">grails hello-world</span><span class="delimiter">&quot;</span></span>
println <span class="string"><span class="delimiter">&quot;</span><span class="content">Hello World</span><span class="delimiter">&quot;</span></span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>description</code> method is used to define the output seen by <code>grails help</code> and to aid users of the script. The following is a more complete example of providing a description taken from the <code>generate-all</code> command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">description( <span class="string"><span class="delimiter">&quot;</span><span class="content">Generates a controller that performs CRUD operations and the associated views</span><span class="delimiter">&quot;</span></span> ) {
usage <span class="string"><span class="delimiter">&quot;</span><span class="content">grails generate-all &lt;&lt;DOMAIN CLASS&gt;&gt;</span><span class="delimiter">&quot;</span></span>
flag <span class="key">name</span>:<span class="string"><span class="delimiter">'</span><span class="content">force</span><span class="delimiter">'</span></span>, <span class="key">description</span>:<span class="string"><span class="delimiter">&quot;</span><span class="content">Whether to overwrite existing files</span><span class="delimiter">&quot;</span></span>
argument <span class="key">name</span>:<span class="string"><span class="delimiter">'</span><span class="content">Domain Class</span><span class="delimiter">'</span></span>, <span class="key">description</span>:<span class="string"><span class="delimiter">'</span><span class="content">The name of the domain class</span><span class="delimiter">'</span></span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>As you can see this description profiles usage instructions, a flag and an argument. This allows the command to be used as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails generate-all MyClass --force</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_template_generation">Template Generation</h4>
<div class="paragraph">
<p>Plugins and applications that need to define template generation tasks can do so using scripts. A example of this is the Scaffolding plugin which defines the <code>generate-all</code> and <code>generate-controllers</code> commands.</p>
</div>
<div class="paragraph">
<p>Every Grails script implements the <a href="https://grails.apache.org/docs/6.2.3/api/org/grails/cli/profile/commands/templates/TemplateRenderer.html">TemplateRenderer</a> interface which makes it trivial to render templates to the users project workspace.</p>
</div>
<div class="paragraph">
<p>The following is an example of the <a href="../ref/Command%20Line/create-script.html">create-script</a> command written in Groovy:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">description( <span class="string"><span class="delimiter">&quot;</span><span class="content">Creates a Grails script</span><span class="delimiter">&quot;</span></span> ) {
usage <span class="string"><span class="delimiter">&quot;</span><span class="content">grails create-script &lt;&lt;SCRIPT NAME&gt;&gt;</span><span class="delimiter">&quot;</span></span>
argument <span class="key">name</span>:<span class="string"><span class="delimiter">'</span><span class="content">Script Name</span><span class="delimiter">'</span></span>, <span class="key">description</span>:<span class="string"><span class="delimiter">&quot;</span><span class="content">The name of the script to create</span><span class="delimiter">&quot;</span></span>
flag <span class="key">name</span>:<span class="string"><span class="delimiter">'</span><span class="content">force</span><span class="delimiter">'</span></span>, <span class="key">description</span>:<span class="string"><span class="delimiter">&quot;</span><span class="content">Whether to overwrite existing files</span><span class="delimiter">&quot;</span></span>
}
<span class="keyword">def</span> scriptName = args[<span class="integer">0</span>]
<span class="keyword">def</span> model = model(scriptName)
<span class="keyword">def</span> overwrite = flag(<span class="string"><span class="delimiter">'</span><span class="content">force</span><span class="delimiter">'</span></span>) ? <span class="predefined-constant">true</span> : <span class="predefined-constant">false</span>
render <span class="key">template</span>: template(<span class="string"><span class="delimiter">'</span><span class="content">artifacts/Script.groovy</span><span class="delimiter">'</span></span>),
<span class="key">destination</span>: file(<span class="string"><span class="delimiter">&quot;</span><span class="content">src/main/scripts/</span><span class="inline"><span class="inline-delimiter">${</span>model.lowerCaseName<span class="inline-delimiter">}</span></span><span class="content">.groovy</span><span class="delimiter">&quot;</span></span>),
<span class="key">model</span>: model,
<span class="key">overwrite</span>: overwrite</code></pre>
</div>
</div>
<div class="paragraph">
<p>If a script is defined in a plugin or profile, the <code>template(String)</code> method will search for the template in the application before using the template provided by your plugin or profile. This allows users of your plugin or profile to customize what gets generated.</p>
</div>
<div class="paragraph">
<p>It is common to provide an easy way to allow users to copy the templates from your plugin or profile. Here is one example on how the angular scaffolding copies templates.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">templates(<span class="string"><span class="delimiter">&quot;</span><span class="content">angular/**/*</span><span class="delimiter">&quot;</span></span>).each { Resource r -&gt;
<span class="predefined-type">String</span> path = r.URL.toString().replaceAll(<span class="regexp"><span class="delimiter">/</span><span class="content">^.*?META-INF</span><span class="delimiter">/</span></span>, <span class="string"><span class="delimiter">&quot;</span><span class="content">src/main</span><span class="delimiter">&quot;</span></span>)
<span class="keyword">if</span> (path.endsWith(<span class="string"><span class="delimiter">'</span><span class="content">/</span><span class="delimiter">'</span></span>)) {
mkdir(path)
} <span class="keyword">else</span> {
<span class="predefined-type">File</span> to = <span class="keyword">new</span> <span class="predefined-type">File</span>(path)
SpringIOUtils.copy(r, to)
println(<span class="string"><span class="delimiter">&quot;</span><span class="content">Copied </span><span class="inline"><span class="inline-delimiter">${</span>r.filename<span class="inline-delimiter">}</span></span><span class="content"> to location </span><span class="inline"><span class="inline-delimiter">${</span>to.canonicalPath<span class="inline-delimiter">}</span></span><span class="delimiter">&quot;</span></span>)
}
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_the_model">The "model"</h4>
<div class="paragraph">
<p>Executing the <code>model</code> method with a <code>Class</code>/<code>String</code>/<code>File</code>/<code>Resource</code> will return an instance of <a href="https://grails.apache.org/docs/6.2.3/api/grails/codegen/model/Model.html">Model</a>. The model contains several properties that can help you generate code.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> domain = model(com.foo.Bar)
domain.className == <span class="string"><span class="delimiter">&quot;</span><span class="content">FooBar</span><span class="delimiter">&quot;</span></span>
domain.fullName == <span class="string"><span class="delimiter">&quot;</span><span class="content">com.foo.FooBar</span><span class="delimiter">&quot;</span></span>
domain.packageName == <span class="string"><span class="delimiter">&quot;</span><span class="content">com.foo</span><span class="delimiter">&quot;</span></span>
domain.packagePath == <span class="string"><span class="delimiter">&quot;</span><span class="content">com/foo</span><span class="delimiter">&quot;</span></span>
domain.propertyName == <span class="string"><span class="delimiter">&quot;</span><span class="content">fooBar</span><span class="delimiter">&quot;</span></span>
domain.lowerCaseName == <span class="string"><span class="delimiter">&quot;</span><span class="content">foo-bar</span><span class="delimiter">&quot;</span></span></code></pre>
</div>
</div>
<div class="paragraph">
<p>In addition, an <code>asMap</code> method is available to turn all of the properties into a map to pass to the <code>render</code> method.</p>
</div>
</div>
<div class="sect3">
<h4 id="_working_with_files">Working with files</h4>
<div class="paragraph">
<p>All scripts have access to methods on the <a href="https://grails.apache.org/docs/6.2.3/api/org/grails/cli/profile/commands/io/FileSystemInteraction.html">FileSystemInteraction</a> class. It contains helpful methods to copy, delete, and create files.</p>
</div>
</div>
<h2 id="creatingCustomCommands">5.3 Creating Custom Commands</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/creatingCustomCommands.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>You can create your own commands by running the <a href="#ref-command-line-create-command">create-command</a> command from the root of your project. For example the following command will create a command called <code>grails-app/commands/HelloWorldCommand</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails create-command HelloWorld</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Unlike scripts, commands cause the Grails environment to start and you have full access to the application context and the runtime.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Since Grails 3.2.0, commands have similar abilities as scripts in regards to retrieving arguments, template generation, file access, and model building.</p>
</div>
<div class="paragraph">
<p>If you created a command in a previous version of grails, you can update your command to have those abilities by changing which trait you are implementing.</p>
</div>
<div class="paragraph">
<p>Commands created in Grails 3.1.x or lower implement the <a href="https://grails.apache.org/docs/latest/api/grails/dev/commands/ApplicationCommand.html">ApplicationCommand</a> trait by default which requires your command to implement the following method:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">boolean</span> handle(ExecutionContext executionContext)</code></pre>
</div>
</div>
<div class="paragraph">
<p>Commands created in Grails 3.2.0 or higher implement the <a href="https://grails.apache.org/docs/latest/api/grails/dev/commands/GrailsApplicationCommand.html">GrailsApplicationCommand</a> trait by default which requires your command to implement the following method:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">boolean</span> handle()</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Commands defined this way still have access to the execution context via a variable called "executionContext".
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Custom commands can be executed using <strong>grails run-command</strong>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code>grails run-command my-example</code></pre>
</div>
</div>
<div class="paragraph">
<p>Commands can also be executed using the <strong>runCommand</strong> gradle task. Note that the gradle task uses camelCase:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code>gradle runCommand -Pargs=&quot;my-example&quot;</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the grails server is a subproject (e.g., in a project created with the <strong>angular</strong> profile), the subproject command can still be invoked from the gradle wrapper in the parent project:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code>./gradlew server:runCommand -Pargs=&quot;my-example&quot;</code></pre>
</div>
</div>
<div class="paragraph">
<p>With Gradle, a custom command is a piece of functionality that you can add to your Grails application and execute via the command-line interface (CLI). These commands are not part of the core Grails framework but are extensions you can create to perform specific tasks or operations that are unique to your application&#8217;s requirements. Custom commands are a powerful way to automate various tasks, interact with your application, and perform administrative functions from the command line. When you run custom commands, they cause the Grails environment to start, giving you full access to the application context and the runtime, allowing you to work with the application&#8217;s resources, services, and configuration as needed within your custom command.</p>
</div>
<div class="paragraph">
<p>There are several reasons why you might want to write a custom command for your Grails application:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Automating Tasks: Custom commands allow you to automate routine tasks, such as data migration, database updates, or batch processing, by encapsulating the logic in a command that can be executed on-demand.</p>
</li>
<li>
<p>Administrative Operations: You can use custom commands for administrative tasks like user management, system maintenance, and configuration management, making it easier to manage your application in different environments.</p>
</li>
<li>
<p>Integration: Custom commands can be used to integrate your Grails application with other systems or services. For example, you can create a command to synchronize data with an external API.</p>
</li>
<li>
<p>Customized Workflows: If your application has unique workflows or processes, custom commands provide a way to execute these workflows from the command line.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In Grails, you can create custom commands by implementing the <a href="https://grails.apache.org/docs/latest/api/grails/dev/commands/GrailsApplicationCommand.html">GrailsApplicationCommand</a> trait. By default, this trait requires your command to implement the handle() method as following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">boolean handle()</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Commands defined this way still have access to the execution context via a variable called "executionContext."</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Here&#8217;s a step-by-step guide on how to create custom commands using the GrailsApplicationCommand trait with examples, and how to run these commands.</p>
</div>
<div class="paragraph">
<p>In Grails, you can create custom commands by implementing the <code>GrailsApplicationCommand</code> trait. Custom commands allow you to add functionality to your Grails application that can be executed via the command-line interface (CLI). Here&#8217;s a step-by-step guide on how to create custom commands using the <code>GrailsApplicationCommand</code> trait with examples, and how to run these commands.</p>
</div>
<div class="paragraph">
<p><strong>Step 1: Create a Custom Command</strong></p>
</div>
<div class="paragraph">
<p>To create a custom command, you need to create a Groovy class that implements the <code>GrailsApplicationCommand</code> trait. This trait provides methods for command execution. Let&#8217;s create a simple example command that greets the user:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">// grails-app/commands/com/example/GreetCommand.groovy</span>
<span class="keyword">package</span> com.example
<span class="keyword">import</span> <span class="include">grails.dev.commands.GrailsApplicationCommand</span>
<span class="type">class</span> <span class="class">GreetCommand</span> <span class="directive">implements</span> GrailsApplicationCommand {
<span class="predefined-type">String</span> getName() {
<span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">greet</span><span class="delimiter">&quot;</span></span>
}
<span class="predefined-type">String</span> getDescription() {
<span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">Greet the user</span><span class="delimiter">&quot;</span></span>
}
<span class="type">boolean</span> handle() {
println(<span class="string"><span class="delimiter">&quot;</span><span class="content">Hello, user!</span><span class="delimiter">&quot;</span></span>)
<span class="keyword">return</span> <span class="predefined-constant">true</span> <span class="comment">// Return true to indicate successful execution</span>
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this example, we&#8217;ve created a <code>GreetCommand</code> class that implements the <code>GrailsApplicationCommand</code> trait. It provides a <code>getName()</code> method to define the command name, a <code>getDescription()</code> method for a brief description, and the <code>run()</code> method to specify the code to execute when the command is run.</p>
</div>
<div class="paragraph">
<p>Step 2: Build Your Grails Application</p>
</div>
<div class="paragraph">
<p>Before you can use the runCommand task, ensure you have built your Grails application using the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">./gradlew assemble</code></pre>
</div>
</div>
<div class="paragraph">
<p>This command will compile your application and make it ready for running custom commands.</p>
</div>
<div class="paragraph">
<p><strong>Step 3: Run the Custom Command</strong></p>
</div>
<div class="paragraph">
<p>To run the custom command, use Gradle&#8217;s runCommand task. Open your terminal and navigate to your Grails application&#8217;s root directory. Then, run the custom command with the following Gradle command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">./gradlew runCommand -Pargs=&quot;greet&quot;</code></pre>
</div>
</div>
<div class="paragraph">
<p>In the command above, replace "greet" with the name of your custom command. This will execute the GreetCommand, and you will see the output.</p>
</div>
<div class="paragraph">
<p>Here&#8217;s the expected final output when you run the greet command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">Hello, user!</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Additional Features: Command Arguments and Options</strong></p>
</div>
<div class="paragraph">
<p>Grails also supports command-line arguments and options for custom commands. You can define these in your command class by implementing the <code>GrailsApplicationCommand</code> interface. Here&#8217;s an example of a command that takes a name as an argument and an optional <code>--loud</code> option to make the greeting louder:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">// grails-app/commands/com/example/GreetCommand.groovy</span>
<span class="keyword">package</span> com.example
<span class="keyword">import</span> <span class="include">grails.dev.commands.GrailsApplicationCommand</span>
<span class="type">class</span> <span class="class">GreetCommand</span> <span class="directive">implements</span> GrailsApplicationCommand {
<span class="predefined-type">String</span> getName() {
<span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">greet</span><span class="delimiter">&quot;</span></span>
}
<span class="predefined-type">String</span> getDescription() {
<span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">Greet the user with options</span><span class="delimiter">&quot;</span></span>
}
<span class="type">boolean</span> handle() {
<span class="keyword">def</span> args = commandLine.args
<span class="predefined-type">String</span> name = args.size() &gt; <span class="integer">0</span> ? args[<span class="integer">0</span>] : <span class="string"><span class="delimiter">&quot;</span><span class="content">user</span><span class="delimiter">&quot;</span></span>
<span class="type">boolean</span> loud = args.contains(<span class="string"><span class="delimiter">&quot;</span><span class="content">--loud</span><span class="delimiter">&quot;</span></span>)
<span class="keyword">if</span> (loud) {
println(<span class="string"><span class="delimiter">&quot;</span><span class="content">HELLO, </span><span class="inline"><span class="inline-delimiter">$</span>name</span><span class="content">! (LOUD)</span><span class="delimiter">&quot;</span></span>)
} <span class="keyword">else</span> {
println(<span class="string"><span class="delimiter">&quot;</span><span class="content">Hello, </span><span class="inline"><span class="inline-delimiter">$</span>name</span><span class="content">!</span><span class="delimiter">&quot;</span></span>)
}
<span class="keyword">return</span> <span class="predefined-constant">true</span>
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you can run the <code>greet</code> command with arguments and options:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell"># Greet the user with the default message
./gradlew runCommand -Pargs=&quot;greet&quot;
# Greet a specific user
./gradlew runCommand -Pargs=&quot;greet Alice&quot;
# Greet loudly
./gradlew runCommand -Pargs=&quot;greet --loud&quot;
# Greet a specific user loudly
./gradlew runCommand -Pargs=&quot;greet Alice --loud&quot;</code></pre>
</div>
</div>
<div class="paragraph">
<p>This allows you to create more versatile and interactive custom commands for your Grails application.</p>
</div>
<div class="paragraph">
<p>In summary, creating custom commands in Grails using the <code>GrailsApplicationCommand</code> trait is a powerful way to extend your application&#8217;s functionality beyond the web interface. You can define the command&#8217;s name, description, and logic, and then execute it from the command line, optionally passing arguments and options as needed.</p>
</div>
<div class="paragraph">
<p><strong>Using the <code>executionContext</code> in the Grails Custom Commands</strong></p>
</div>
<div class="paragraph">
<p>In Grails, the executionContext is a runtime context object that provides valuable information about the current execution environment of a Grails application. It includes details such as the application&#8217;s environment (e.g., development, production, test) and allows developers to access this context within custom commands.</p>
</div>
<div class="paragraph">
<p>Custom commands in Grails can use the executionContext to make informed decisions and perform specific tasks based on the current runtime environment. For example, developers can write conditional logic in custom commands that execute differently in production, development, or testing environments. This flexibility enables custom commands to adapt and behave differently depending on the context in which they are run, making them versatile tools for managing and extending Grails applications.</p>
</div>
<div class="paragraph">
<p>Suppose you have a Grails application that manages customer data, and you want to create a custom command to perform data backup. In this scenario, you may want the backup process to behave differently depending on whether you&#8217;re running it in a development, staging, or production environment.</p>
</div>
<div class="paragraph">
<p>Here&#8217;s an example of how you can create a custom command that uses the executionContext to determine the backup behavior:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">// grails-app/commands/com/example/BackupCommand.groovy</span>
<span class="keyword">package</span> com.example
<span class="keyword">import</span> <span class="include">grails.dev.commands.GrailsApplicationCommand</span>
<span class="type">class</span> <span class="class">BackupCommand</span> <span class="directive">implements</span> GrailsApplicationCommand {
<span class="predefined-type">String</span> getName() {
<span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">backup</span><span class="delimiter">&quot;</span></span>
}
<span class="predefined-type">String</span> getDescription() {
<span class="keyword">return</span> <span class="string"><span class="delimiter">&quot;</span><span class="content">Backup customer data</span><span class="delimiter">&quot;</span></span>
}
<span class="type">boolean</span> handle() {
<span class="comment">// Access the executionContext to determine the environment</span>
<span class="keyword">def</span> environment = executionContext.environment
<span class="keyword">if</span> (environment == <span class="string"><span class="delimiter">&quot;</span><span class="content">production</span><span class="delimiter">&quot;</span></span>) {
<span class="comment">// Perform a full backup in the production environment</span>
println(<span class="string"><span class="delimiter">&quot;</span><span class="content">Performing a full backup of customer data (Production)</span><span class="delimiter">&quot;</span></span>)
<span class="comment">// Add production-specific backup logic here</span>
} <span class="keyword">else</span> {
<span class="comment">// Perform a partial backup in other environments</span>
println(<span class="string"><span class="delimiter">&quot;</span><span class="content">Performing a partial backup of customer data (Non-production)</span><span class="delimiter">&quot;</span></span>)
<span class="comment">// Add non-production backup logic here</span>
}
<span class="keyword">return</span> <span class="predefined-constant">true</span> <span class="comment">// Return true to indicate successful execution</span>
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this example:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The custom command, named <code>BackupCommand</code>, is created to back up customer data.</p>
</li>
<li>
<p>It checks the <code>executionContext</code> to determine the current environment.</p>
</li>
<li>
<p>If the environment is "production," it performs a full backup with production-specific logic.</p>
</li>
<li>
<p>In all other environments, it performs a partial backup with non-production logic.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>When you run this custom command using <code>./gradlew runCommand -Pargs="backup"</code>, it will adapt its behavior based on whether you&#8217;re in a production or non-production environment, demonstrating how the <code>executionContext</code> can be used to make environment-specific decisions in a realistic scenario.</p>
</div>
<div class="paragraph">
<p><strong>How to Create a Custom Command from a Grails Plugin</strong></p>
</div>
<div class="paragraph">
<p>You can create custom commands not only within your Grails application but also from a Grails plugin. Here&#8217;s how to do it:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Create a Grails Plugin:</strong> If you don&#8217;t already have a Grails plugin, you can create one using Grails' plugin generation commands. For example:</p>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-plugin my-plugin</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Define the Command:</strong> Inside your Grails plugin, define the custom command by creating a Groovy class that implements the <code>GrailsApplicationCommand</code> trait or interface, providing the necessary methods like <code>getName()</code>, <code>getDescription()</code>, and <code>handle()</code>.</p>
</li>
<li>
<p><strong>Build and Package the Plugin:</strong> To publish the plugin, you should use the Gradle maven-publish plugin. Update your plugin&#8217;s build.gradle file to include the following configuration:</p>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
url <span class="string"><span class="delimiter">&quot;</span><span class="content">file://path/to/your/local/repo</span><span class="delimiter">&quot;</span></span> <span class="comment">// Adjust the path accordingly</span>
}
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then, you can publish the plugin to your local repository:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">./gradlew publishToMavenLocal</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Add the Plugin as a Dependency:</strong> Instead of using the grails install-plugin command, you should add the plugin as a dependency in your Grails application&#8217;s build.gradle file. Include the following dependency:</p>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">dependencies {
<span class="comment">// ...</span>
implementation <span class="string"><span class="delimiter">'</span><span class="content">com.example:my-plugin:1.0.0</span><span class="delimiter">'</span></span> <span class="comment">// Replace with your plugin's group and version</span>
<span class="comment">// ...</span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Make sure to replace "com.example:my-plugin:1.0.0" with the appropriate group and version for your plugin</p>
</div>
</li>
<li>
<p><strong>Run the Custom Command:</strong> Now, you can run the custom command from your Grails application&#8217;s root directory using the Gradle <code>runCommand</code> task, as previously explained:</p>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">./gradlew runCommand -Pargs=&quot;your-command-name&quot;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Replace <code>"your-command-name"</code> with the name of the custom command you defined in your plugin.</p>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>By following these steps, you can create and run custom commands from a Grails plugin, extending the functionality of your Grails application as needed. This approach allows you to modularize your custom functionality and share it across multiple Grails projects if necessary.</p>
</div>
<h2 id="creatingProject">5.4 Creating a Grails Project</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/creatingProject.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>Creating a project is the primary usage of the CLI. The primary command for creating a new project is create-app, which creates a standard Grails web application that communicates over HTTP. For other types of application, see the documentation below.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 6.25%;">
<col style="width: 18.75%;">
<col style="width: 25%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Command</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Options</th>
<th class="tableblock halign-left valign-top">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">create-app / create-webapp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Creates a Grails web application</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="ulist none">
<ul class="none">
<li>
<p>-jdk, --java-version</p>
</li>
<li>
<p>-s, --servlet</p>
</li>
<li>
<p>-g, --gorm</p>
</li>
<li>
<p>-t, --test</p>
</li>
<li>
<p>-f, --features</p>
</li>
<li>
<p>-i, --inplace</p>
</li>
</ul>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-app \
--servlet=tomcat \
--jdk=11 \
--gorm=hibernate \
--test=spock \
--features=github-workflow-java-ci \
com.example.demo`</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">create-restapi</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Creates a Grails REST API application</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="ulist none">
<ul class="none">
<li>
<p>-jdk, --java-version</p>
</li>
<li>
<p>-s, --servlet</p>
</li>
<li>
<p>-g, --gorm</p>
</li>
<li>
<p>-t, --test</p>
</li>
<li>
<p>-f, --features</p>
</li>
<li>
<p>-i, --inplace</p>
</li>
</ul>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-restapi \
--servlet=tomcat \
--jdk=11 \
--gorm=hibernate \
--test=spock \
--features=github-workflow-java-ci \
com.example.demo`</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">create-plugin</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Creates a Grails Plugin application</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="ulist none">
<ul class="none">
<li>
<p>-jdk, --java-version</p>
</li>
<li>
<p>-s, --servlet</p>
</li>
<li>
<p>-g, --gorm</p>
</li>
<li>
<p>-t, --test</p>
</li>
<li>
<p>-f, --features</p>
</li>
<li>
<p>-i, --inplace</p>
</li>
</ul>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-plugin \
--servlet=tomcat \
--jdk=11 \
--gorm=hibernate \
--test=spock \
--features=github-workflow-java-ci \
com.example.demo`</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">create-web-plugin</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Creates a Grails Web Plugin application</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="ulist none">
<ul class="none">
<li>
<p>-jdk, --java-version</p>
</li>
<li>
<p>-s, --servlet</p>
</li>
<li>
<p>-g, --gorm</p>
</li>
<li>
<p>-t, --test</p>
</li>
<li>
<p>-f, --features</p>
</li>
<li>
<p>-i, --inplace</p>
</li>
</ul>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">grails create-web-plugin \
--servlet=tomcat \
--jdk=11 \
--gorm=hibernate \
--test=spock \
--features=github-workflow-java-ci \
com.example.demo`</code></pre>
</div>
</div></div></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>| Flag | Description | Example</p>
</div>
<div class="sect2">
<h3 id="_the_create_command_flags">The <code>create-</code> command flags</h3>
<div class="paragraph">
<p>The "create-*" commands are used to produce a fundamental Grails project, allowing for the inclusion of optional flags to select additional features, to customize GORM settings, an embedded servlet, the test framework, and the Java version.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 22.2222%;">
<col style="width: 44.4444%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Flag</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">-jdk, --java-version</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The JDK version the project should target</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">--java-version 11</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">-s, --servlet</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Which Servlet Implementation to configure. Possible values: none, tomcat,
jetty, undertow.</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">--servlet=tomcat</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">-g, --gorm</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Which GORM Implementation to configure. Possible values: hibernate,
mongodb, neo4j.</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">--gorm hibernate</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">-t, --test</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Which test framework to use. Possible values: junit, spock.</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">--test spock</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">-f, --features</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The features to use. Possible values: h2, gorm-hibernate5, spring-boot-starter-jetty, springloaded, micronaut-http-client, cache-ehcache, hibernate-validator, postgres, mysql, cache, database-migration, grails-gsp, hamcrest, gorm-mongodb, assertj, mockito, spring-boot-starter-undertow, micronaut-inject-groovy, github-workflow-java-ci, jrebel, testcontainers, sqlserver, grails-console, views-markup, views-json, gorm-neo4j, asciidoctor, embedded-mongodb, grails-web-console, logbackGroovy, mongo-sync, shade, properties</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">--features github-workflow-java-ci,micronaut-http-client</code></pre>
</div>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">-i, --inplace</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create a project using the current directory</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="shell">--inplace</code></pre>
</div>
</div></div></td>
</tr>
</tbody>
</table>
</div>
<a name="4.2 Re-using Grails scripts"><!-- Legacy link --></a>
<h2 id="reusingGrailsScripts">5.5 Re-using Grails scripts</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/reusingGrailsScripts.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>Grails ships with a lot of command line functionality out of the box that you may find useful in your own scripts (See the command line reference in the reference guide for info on all the commands).</p>
</div>
<div class="paragraph">
<p>Any script you create can invoke another Grails script simply by invoking a method:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">testApp()</code></pre>
</div>
</div>
<div class="paragraph">
<p>The above will invoke the <code>test-app</code> command. You can also pass arguments using the method arguments:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">testApp(<span class="string"><span class="delimiter">'</span><span class="content">--debug-jvm</span><span class="delimiter">'</span></span>)</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_invoking_gradle">Invoking Gradle</h4>
<div class="paragraph">
<p>Instead of invoking another Grails CLI command you can invoke Gradle directory using the <code>gradle</code> property.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">gradle.compileGroovy()</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_invoking_ant">Invoking Ant</h4>
<div class="paragraph">
<p>You can also invoke Ant tasks from scripts which can help if you need to writing code generation and automation tasks:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">ant.mkdir(<span class="key">dir</span>:<span class="string"><span class="delimiter">&quot;</span><span class="content">path</span><span class="delimiter">&quot;</span></span>)</code></pre>
</div>
</div>
</div>
<h2 id="gradleBuild">5.6 Building with Gradle</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/gradleBuild.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>Since Grails 3.1 the <a href="http://gradle.org">Gradle Build System</a> is used for build related tasks such as compilation, runnings tests and producing binary distributions of your project. It is recommended to use Gradle 2.2 or above with Grails 3.1 (and higher).</p>
</div>
<div class="paragraph">
<p>The build is defined by the <code>build.gradle</code> file which specifies the version of your project, the dependencies of the project and the repositories where to find those dependencies (amongst other things).</p>
</div>
<div class="paragraph">
<p>When you invoke the <code>grails</code> command the version of Gradle that ships with Grails 3.1 (currently 2.9) is invoked by the <code>grails</code> process via the <a href="http://www.gradle.org/docs/current/userguide/embedding.html">Gradle Tooling API</a>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash"># Equivalent to 'gradle classes'
$ grails compile</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can invoke Gradle directly using the <code>gradle</code> command and use your own local version of Gradle, however you will need Gradle 2.2 or above to work with Grails 3.0 (and higher):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">$ gradle assemble</code></pre>
</div>
</div>
<h2 id="gradleDependencies">5.6.1 Defining Dependencies with Gradle</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/gradleBuild/gradleDependencies.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>Dependencies for your project are defined in the <code>dependencies</code> block. In general, you can follow the <a href="http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html">Gradle documentation on dependency management</a> to understand how to configure additional dependencies.</p>
</div>
<div class="paragraph">
<p>The default dependencies for the Grails Web application can be seen below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">dependencies {
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-core</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-logging</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-plugin-databinding</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-plugin-i18n</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-plugin-interceptors</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-plugin-rest</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-plugin-services</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-plugin-url-mappings</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-web-boot</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails.plugins:gsp</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails.plugins:hibernate5</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails.plugins:scaffolding</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.hibernate:hibernate-core:5.6.15.Final</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.springframework.boot:spring-boot-autoconfigure</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.springframework.boot:spring-boot-starter</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.springframework.boot:spring-boot-starter-actuator</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.springframework.boot:spring-boot-starter-logging</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.springframework.boot:spring-boot-starter-tomcat</span><span class="delimiter">&quot;</span></span>)
implementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.springframework.boot:spring-boot-starter-validation</span><span class="delimiter">&quot;</span></span>)
compileOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">io.micronaut:micronaut-inject-groovy</span><span class="delimiter">&quot;</span></span>)
console(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-console</span><span class="delimiter">&quot;</span></span>)
runtimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">com.bertramlabs.plugins:asset-pipeline-grails:4.3.0</span><span class="delimiter">&quot;</span></span>)
runtimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">com.h2database:h2</span><span class="delimiter">&quot;</span></span>)
runtimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">javax.xml.bind:jaxb-api:2.3.1</span><span class="delimiter">&quot;</span></span>)
runtimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.apache.tomcat:tomcat-jdbc</span><span class="delimiter">&quot;</span></span>)
runtimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.fusesource.jansi:jansi:1.18</span><span class="delimiter">&quot;</span></span>)
runtimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.glassfish.web:el-impl:2.2.1-b05</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">io.micronaut:micronaut-inject-groovy</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-gorm-testing-support</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails:grails-web-testing-support</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails.plugins:geb</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.seleniumhq.selenium:selenium-api:4.10.0</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.seleniumhq.selenium:selenium-remote-driver:4.10.0</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.seleniumhq.selenium:selenium-support:4.10.0</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.spockframework:spock-core</span><span class="delimiter">&quot;</span></span>)
testRuntimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.seleniumhq.selenium:selenium-chrome-driver:4.10.0</span><span class="delimiter">&quot;</span></span>)
testRuntimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.seleniumhq.selenium:selenium-firefox-driver:4.10.0</span><span class="delimiter">&quot;</span></span>)
testRuntimeOnly(<span class="string"><span class="delimiter">&quot;</span><span class="content">org.seleniumhq.selenium:selenium-safari-driver:4.10.0</span><span class="delimiter">&quot;</span></span>)
testImplementation(<span class="string"><span class="delimiter">&quot;</span><span class="content">io.micronaut:micronaut-http-client</span><span class="delimiter">&quot;</span></span>)
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that version numbers are not present in the majority of the dependencies. This is thanks to the dependency management plugin which configures a Maven BOM that defines the default dependency versions for certain commonly used dependencies and plugins:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">dependencyManagement {
imports {
mavenBom <span class="string"><span class="delimiter">'</span><span class="content">org.grails:grails-bom:</span><span class="delimiter">'</span></span> + grailsVersion
}
applyMavenExclusions <span class="predefined-constant">false</span>
}</code></pre>
</div>
</div>
<h2 id="gradleTasks">5.6.2 Working with Gradle Tasks</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/gradleBuild/gradleTasks.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>As mentioned previously the <code>grails</code> command uses an embedded version of Gradle and certain Grails commands that existed in previous versions of Grails map onto their Gradle equivalents. The following table shows which Grails command invoke which Gradle task:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>Grails Command</strong></th>
<th class="tableblock halign-left valign-top"><strong>Gradle Task</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">clean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">clean</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">compile</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">classes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">package</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">assemble</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">run-app</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">bootRun</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">test-app</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">check</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">test-app --unit</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">test</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">test-app --integration</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integrationTest</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">war</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">assemble</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>You can invoke any of these Grails commands using their Gradle equivalents if you prefer:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">$ gradle test</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note however that you will need to use a version of Gradle compatible with Grails 3.1 (Gradle 2.2 or above). If you wish to invoke a Gradle task using the version of Gradle used by Grails you can do so with the <code>grails</code> command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">$ grails gradle compileGroovy</code></pre>
</div>
</div>
<div class="paragraph">
<p>However, it is recommended you do this via interactive mode, as it greatly speeds up execution and provides TAB completion for the available Gradle tasks:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">$ grails
| Enter a command name to run. Use TAB for completion:
grails&gt; gradle compileGroovy
...</code></pre>
</div>
</div>
<div class="paragraph">
<p>To find out what Gradle tasks are available without using interactive mode TAB completion you can use the Gradle <code>tasks</code> task:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">gradle tasks</code></pre>
</div>
</div>
<h2 id="gradlePlugins">5.6.3 Grails plugins for Gradle</h2>
<div class='contribute-btn'>
<button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/6.2.x/src/en/guide/commandLine/gradleBuild/gradlePlugins.adoc"'>
<i class='fa fa-pencil-square-o'></i> Improve this doc
</button>
</div>
<div class="paragraph">
<p>When you create a new project with the <a href="../ref/Command%20Line/create-app.html">create-app</a> command, a default <code>build.gradle</code> is created. The default <code>build.gradle</code> configures the build with a set of Gradle plugins that allow Gradle to build the Grails project:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">plugins {
id <span class="string"><span class="delimiter">&quot;</span><span class="content">groovy</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails.grails-web</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">org.grails.grails-gsp</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">com.github.erdi.webdriver-binaries</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">war</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">idea</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">com.bertramlabs.asset-pipeline</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">application</span><span class="delimiter">&quot;</span></span>
id <span class="string"><span class="delimiter">&quot;</span><span class="content">eclipse</span><span class="delimiter">&quot;</span></span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The default plugins are as follows:
* <code>groovy</code> - The Groovy plugin add support for Groovy projects. It can deal with Groovy code mixed with Groovy and Java. Read More: <a href="https://docs.gradle.org/7.6.4/userguide/groovy_plugin.html">The Groovy Plugin</a>
* <code>com.github.erdi.webdriver-binaries</code> - A plugin that downloads and caches WebDriver binaries specific to the OS the build runs on. Read More at <a href="https://github.com/erdi/webdriver-binaries-gradle-plugin/blob/master/README.md">GitHub README</a>
* <code>war</code> - The <a href="https://docs.gradle.org/7.6.4/userguide/war_plugin.html">The WAR plugin</a> changes the packaging so that Gradle creates as WAR file from your application. You can comment out this plugin if you wish to create only a runnable JAR file for standalone deployment.
* <code>idea</code> - The IDEA plugin generates files that are used by <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a>, thus making it possible to open the project from IDEA. Read More: <a href="https://docs.gradle.org/7.6.4/userguide/idea_plugin.html">The IDEA Plugin</a>
* <code>com.bertramlabs.asset-pipeline</code> - The <a href="https://grails.org/plugins.html#plugin/asset-pipeline">asset pipeline</a> plugin enables the compilation of static assets (JavaScript, CSS etc.)
* <code>application</code> - The Application plugin facilitates creating an executable JVM application. Read More: <a href="https://docs.gradle.org/7.6.4/userguide/application_plugin.html">The Application Plugin</a>
* <code>eclipse</code> - The Eclipse plugins generate files that are used by the <a href="http://eclipse.org/">Eclipse IDE</a>, thus making it possible to import the project into Eclipse (File - Import&#8230;&#8203; - Existing Projects into Workspace). Read More: <a href="https://docs.gradle.org/7.6.4/userguide/eclipse_plugin.html">The Eclipse Plugin</a></p>
</div>
<div class="paragraph">
<p>Many of these are built in plugins provided by Gradle or third party plugins. The Gradle plugins that Grails provides are as follows:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>org.grails.grails-doc</code> - A plugin for Gradle for using Grails 2.0&#8217;s documentation engine.</p>
</li>
<li>
<p><code>org.grails.grails-gsp</code> - The Grails GSP plugin adds pre-compilation of GSP files for production deployments.</p>
</li>
<li>
<p><code>org.grails.grails-plugin</code> - A plugin for Gradle for building Grails plugins.</p>
</li>
<li>
<p><code>org.grails.grails-web</code> - The Grails Web gradle plugin configures Gradle to understand the Grails conventions and directory structure.</p>
</li>
<li>
<p><code>org.grails.grails-plugin-publish</code> - A plugin for publishing Grails plugins to the central repository.</p>
</li>
<li>
<p><code>org.grails.grails-profile</code> - A plugin for use when creating Grails <a href="#profiles">Profiles</a>.</p>
</li>
<li>
<p><code>org.grails.grails-profile-publish</code> - A plugin for publishing Grails profiles to the central repository.</p>
</li>
</ul>
</div>
<div style="clear:both;margin-top:15px;"></div>
<div class="toc-item prev-left"><a href="../guide/conf.html">&lt;&lt; <strong>4</strong><span>Configuration</span></a></div>
<div class="toc-item next-right"><a href="../guide/profiles.html"><strong>6</strong><span>Application Profiles</span> >></a></div>
<div style="clear:both"></div>
</div>
</td>
<td id="col2">
<div class="local clearfix">
<div class="local-title">
<a href="../guide/index.html" target="mainFrame">Quick Reference</a>
<span class="toggle">(<a href="#" onclick="localToggle(); return false;">hide</a>)</span>
</div>
<div class="menu">
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Command Line</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Command%20Line/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Command%20Line/assemble.html">assemble</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/bootRun.html">bootRun</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/bug-report.html">bug-report</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/clean.html">clean</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/compile.html">compile</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/console.html">console</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-app.html">create-app</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-command.html">create-command</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-controller.html">create-controller</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-domain-class.html">create-domain-class</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-functional-test.html">create-functional-test</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-hibernate-cfg-xml.html">create-hibernate-cfg-xml</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-integration-test.html">create-integration-test</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-interceptor.html">create-interceptor</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-job.html">create-job</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-plugin.html">create-plugin</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-profile.html">create-profile</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-restapi.html">create-restapi</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-script.html">create-script</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-service.html">create-service</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-taglib.html">create-taglib</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-unit-test.html">create-unit-test</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/create-web-plugin.html">create-web-plugin</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/dependency-report.html">dependency-report</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/docs.html">docs</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/generate-all.html">generate-all</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/generate-controller.html">generate-controller</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/generate-views.html">generate-views</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/help.html">help</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/install-templates.html">install-templates</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/list-features.html">list-features</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/list-plugins.html">list-plugins</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/list-profiles.html">list-profiles</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/package-plugin.html">package-plugin</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/package.html">package</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/plugin-info.html">plugin-info</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/profile-info.html">profile-info</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/run-app.html">run-app</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/run-command.html">run-command</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/run-script.html">run-script</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/schema-export.html">schema-export</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/shell.html">shell</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/stats.html">stats</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/stop-app.html">stop-app</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/test-app.html">test-app</a>
</div>
<div class="menu-item"><a href="../ref/Command%20Line/war.html">war</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Constraints</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Constraints/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Constraints/attributes.html">attributes</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/bindable.html">bindable</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/blank.html">blank</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/creditCard.html">creditCard</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/email.html">email</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/inList.html">inList</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/matches.html">matches</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/max.html">max</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/maxSize.html">maxSize</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/min.html">min</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/minSize.html">minSize</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/notEqual.html">notEqual</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/nullable.html">nullable</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/range.html">range</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/scale.html">scale</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/size.html">size</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/unique.html">unique</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/url.html">url</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/validator.html">validator</a>
</div>
<div class="menu-item"><a href="../ref/Constraints/widget.html">widget</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Controllers</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Controllers/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Controllers/actionName.html">actionName</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/allowedMethods.html">allowedMethods</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/bindData.html">bindData</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/chain.html">chain</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/controllerName.html">controllerName</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/defaultAction.html">defaultAction</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/errors.html">errors</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/flash.html">flash</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/forward.html">forward</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/grailsApplication.html">grailsApplication</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/hasErrors.html">hasErrors</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/header.html">header</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/namespace.html">namespace</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/params.html">params</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/redirect.html">redirect</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/render.html">render</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/request.html">request</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/respond.html">respond</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/response.html">response</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/responseFormats.html">responseFormats</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/scope.html">scope</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/servletContext.html">servletContext</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/session.html">session</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/withForm.html">withForm</a>
</div>
<div class="menu-item"><a href="../ref/Controllers/withFormat.html">withFormat</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Database Mapping</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Database%20Mapping/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Database%20Mapping/autoImport.html">autoImport</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/autoTimestamp.html">autoTimestamp</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/batchSize.html">batchSize</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/cache.html">cache</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/cascade.html">cascade</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/column.html">column</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/comment.html">comment</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/discriminator.html">discriminator</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/dynamicInsert.html">dynamicInsert</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/dynamicUpdate.html">dynamicUpdate</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/fetch.html">fetch</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/id.html">id</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/ignoreNotFound.html">ignoreNotFound</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/indexColumn.html">indexColumn</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/insertable.html">insertable</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/joinTable.html">joinTable</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/lazy.html">lazy</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/order.html">order</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/sort.html">sort</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/table.html">table</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/type.html">type</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/updateable.html">updateable</a>
</div>
<div class="menu-item"><a href="../ref/Database%20Mapping/version.html">version</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Dependency Versions</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Dependency%20Versions/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Dependency%20Versions/Grails%20BOM.html">Grails BOM</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Domain Classes</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Domain%20Classes/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Domain%20Classes/addTo.html">addTo</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/attach.html">attach</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/belongsTo.html">belongsTo</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/clearErrors.html">clearErrors</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/constraints.html">constraints</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/count.html">count</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/countBy.html">countBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/createCriteria.html">createCriteria</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/delete.html">delete</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/discard.html">discard</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/embedded.html">embedded</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/errors.html">errors</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/executeQuery.html">executeQuery</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/executeUpdate.html">executeUpdate</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/exists.html">exists</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/fetchMode.html">fetchMode</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/find.html">find</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findAll.html">findAll</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findAllBy.html">findAllBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findAllWhere.html">findAllWhere</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findBy.html">findBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findOrCreateBy.html">findOrCreateBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findOrCreateWhere.html">findOrCreateWhere</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findOrSaveBy.html">findOrSaveBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findOrSaveWhere.html">findOrSaveWhere</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/findWhere.html">findWhere</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/first.html">first</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/get.html">get</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/getAll.html">getAll</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/getDirtyPropertyNames.html">getDirtyPropertyNames</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/getPersistentValue.html">getPersistentValue</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/hasErrors.html">hasErrors</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/hasMany.html">hasMany</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/hasOne.html">hasOne</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/ident.html">ident</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/instanceOf.html">instanceOf</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/isAttached.html">isAttached</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/isDirty.html">isDirty</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/last.html">last</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/list.html">list</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/listOrderBy.html">listOrderBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/load.html">load</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/lock.html">lock</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/mapWith.html">mapWith</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/mappedBy.html">mappedBy</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/mapping.html">mapping</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/merge.html">merge</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/namedQueries.html">namedQueries</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/properties.html">properties</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/read.html">read</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/refresh.html">refresh</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/removeFrom.html">removeFrom</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/save.html">save</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/transients.html">transients</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/validate.html">validate</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/where.html">where</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/whereAny.html">whereAny</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/withCriteria.html">withCriteria</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/withNewSession.html">withNewSession</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/withSession.html">withSession</a>
</div>
<div class="menu-item"><a href="../ref/Domain%20Classes/withTransaction.html">withTransaction</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Plug-ins</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Plug-ins/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Plug-ins/URL%20mappings.html">URL mappings</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/codecs.html">codecs</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/controllers.html">controllers</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/core.html">core</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/dataSource.html">dataSource</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/domainClasses.html">domainClasses</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/hibernate.html">hibernate</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/i18n.html">i18n</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/logging.html">logging</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/scaffolding.html">scaffolding</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/services.html">services</a>
</div>
<div class="menu-item"><a href="../ref/Plug-ins/servlets.html">servlets</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Services</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Services/Usage.html">Usage</a></div>
<div class="menu-item"><a href="../ref/Services/scope.html">scope</a>
</div>
</div>
</div>
<div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Servlet API</h1><div class="menu-sub">
<div class="menu-item"><a href="../ref/Servlet%20API/request.html">request</a>
</div>
<div class="menu-item"><a href="../ref/Servlet%20API/response.html">response</a>
</div>
<div class="menu-item"><a href="../ref/Servlet%20API/servletContext.html">servletContext</a>
</div>
<div class="menu-item"><a href="../ref/Servlet%20API/session.html">session</a>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
</table>
<div id="footer">
Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
</div>
<script type="text/javascript" src="../js/docs.js"></script>
</body>
</html>