To start Grails in interactive mode we simply type grails on the command line. This starts Grails and we get an environment to run Grails commands like compile and run-app. Since Grails 3 the underlying build system has changed from Gant to Gradle. We can invoke Gradle tasks in interactive mode with the gradle command. Just like we would use Gradle from the command line we can run the same tasks, but this time when Grails is in interactive mode. Grails will use the Gradle version that belongs to the current Grails version. We even get TAB completion for Gradle tasks.

In the next example we start Grails in interactive mode and run the Gradle task components:

$ grails
| Enter a command name to run. Use TAB for completion:
grails> gradle components
:components

------------------------------------------------------------
Root project
------------------------------------------------------------

No components defined for this project.

Additional source sets
----------------------
Java source 'main:java'
    src/main/java
JVM resources 'main:resources'
    src/main/resources
    grails-app/views
    grails-app/i18n
    grails-app/conf
Java source 'test:java'
    src/test/java
JVM resources 'test:resources'
    src/test/resources
Java source 'integrationTest:java'
    src/integrationTest/java
JVM resources 'integrationTest:resources'
    src/integrationTest/resources

Additional binaries
-------------------
Classes 'integrationTest'
    build using task: :integrationTestClasses
    platform: java8
    tool chain: JDK 8 (1.8)
    classes dir: build/classes/integrationTest
    resources dir: build/resources/integrationTest
Classes 'main'
    build using task: :classes
    platform: java8
    tool chain: JDK 8 (1.8)
    classes dir: build/classes/main
    resources dir: build/resources/main
Classes 'test'
    build using task: :testClasses
    platform: java8
    tool chain: JDK 8 (1.8)
    classes dir: build/classes/test
    resources dir: build/resources/test

Note: currently not all plugins register their components, so some components may not be visible here.

BUILD SUCCESSFUL

Total time: 0.506 secs

Next we invoke gradle compile followed by TAB. We get all the Gradle tasks that start with compile:

grails> gradle compile<TAB>

compileGroovy                  compileGroovyPages
compileIntegrationTestGroovy   compileIntegrationTestJava
compileJava                    compileTestGroovy
compileTestJava                compileWebappGroovyPages
grails>

Written with Grails 3.0.8.

Original article

shadow-left