Skip to content

Support the Grails 9 command line for projects of Grails 9 and later - #477

Open
jdaugherty wants to merge 4 commits into
apache:mainfrom
jdaugherty:feat/grails-9-cli
Open

jdaugherty wants to merge 4 commits into
apache:mainfrom
jdaugherty:feat/grails-9-cli

Conversation

@jdaugherty

@jdaugherty jdaugherty commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Grails 9 publishes no Grails shell. apache/grails-core#17114 (issue apache/grails-core#16348) replaces the shell and the Grails Forge CLI with one command line, and its upgrade note 51, "IDEs and Tools That Started the Grails Shell" (grails-doc/src/en/guide/upgrading/upgrading90x.adoc in that pull request), says what an IDE does instead:

  • the build commands are Gradle tasks the IDE's Gradle support runs (bootRun, test, integrationTest, testApp, assemble, runCommand, runScriptCommand);
  • a tool that starts the command line uses org.apache.grails:grails-cli and the start class its jar names, with --plain-output --non-interactive, and asks help --json for the commands of a directory instead of carrying a list of its own;
  • .grails/project.yml marks a project Grails 9 generated; the version a project is on is grailsVersion.

Today the plugin starts org.grails.cli.GrailsCli of org.apache.grails:grails-shell-cli for every Gradle Grails project and offers a hard-coded list of 34 shell commands. For a Grails 9 project the shell artifact does not exist, so there are no Grails commands and no Grails run configuration, and the list names commands Grails 9 removed. This pull request follows the contract above for projects of Grails 9 and later and leaves Grails 7 and 8 (and earlier) on the shell, unchanged.

The plugin can be released before Grails 9.0. apache/grails-core#17114 is not merged: every 9.0.0-SNAPSHOT published until it is (such as the one in the ASF snapshot repository today) has a grails-cli jar whose start class, org.apache.grails.cli.DelegatingShellApplication, hands the command to the Grails shell, which has no help --json, and that build still publishes grails-shell-cli. The contract (option names, the members of help --json, the start class) can also change before 9.0.0. So the plugin does not choose the command line by the version alone: it asks the jar what it is, falls back to the shell of an earlier build, and degrades to "commands run, names not completed" with one notice when the answer is not one it reads. Grails 9 snapshots and milestones can be tested with a released plugin either way.

Version switch. A project is a project of Grails 9 and later when the major version of grailsVersion (as the Gradle import records it) is 9 or more; 9.0.0-SNAPSHOT, 9.0.0-M1 and 10.x included. The rule is one class, GrailsCommandLine in libs/gradle-tooling, used both inside the Gradle import and in the IDE. The .grails/project.yml record does not switch it: grails project migrate writes that record for an application still on Grails 8, and the Grails 9 command line refuses such a project too. The version decides what is resolved and that run-app and the tests run with Gradle; which command line runs the other commands is decided as described next.

Resolving (GrailsModuleModelBuilderImpl). For Grails 9+ the tooling model builder resolves org.apache.grails:grails-cli:<grailsVersion>:all, not transitive, through a detached configuration, as it resolves the shell today. The all jar is the one the Grails wrapper downloads and the distribution ships: it holds the command line and every class it needs, and its manifest names the start class. The plain jar would pull in the Gradle Tooling API, which is not on Maven Central (the same problem the shell has today). It also resolves org.apache.grails:grails-shell-cli:<grailsVersion> with its dependencies, exactly as for Grails 8, for the builds of Grails 9 that still have the shell. A release of Grails 9 has no shell, so a shell that cannot be resolved is not reported; when neither can be resolved, the Build tool window says so once ("Grails command line could not be resolved", naming both), and the module keeps its Grails support. The model carries the jar of the command line in a new field, commandLineUrls, next to the existing shellUrls; a project imported before this change has no command line jar in its model and runs the shell it has until it is reloaded.

Which command line (Grails9CommandLineProbe, Grails9CommandLines). For a Grails 9+ project the plugin starts the resolved jar once as a tool starts the command line, java -XX:TieredStopAtLevel=1 -cp <jar> <Main-Class> --plain-output --non-interactive help --json, with the IDE's own Java runtime, in an empty temporary directory, with GRAILS_PREFERRED_SHELL=forge in its environment, and stops it after 30 seconds. The answer is kept for the jar as it is on disk (path, size and modification time; a snapshot replaced in place is asked again), for the IDE session, and shared by all projects; it is computed on a pooled thread and never waited for on the event dispatch thread, where the Grails 9 command line is assumed until the answer is in (the jar is asked as soon as the Grails applications of a project are known, so the answer is normally in long before a command is typed). The variable matters for the earlier builds: their start class reads it and then starts the old Forge CLI, which refuses the options in about a second with exit code 2; without it, the shell they start resolves its profiles and starts Gradle, about 60 seconds outside a project and 100 inside one, and ends with exit code 1. The Grails 9 command line does not read it (its upgrade notes say so, and GrailsCliSpec tests it). The answer is one of:

  • a document of format 1 (exit code 0): the Grails 9 command line; its commands run there, and completion offers what help --json lists in the project;
  • a JSON document whose format is another number: the Grails 9 command line of a later contract; commands still run there, without completion;
  • anything else (a non-zero exit code, output that is not such a document, a jar that could not be started) or no answer within 30 seconds: not the Grails 9 command line. The commands run in the Grails shell of the version when the import resolved it, as for Grails 8 (shell commands, shell completion, the shell executors); without a shell they run in the command line as typed, without completion.

When the Grails 9 side changes. Every outcome other than format 1 gives one notification (group "Grails command line") for each project and jar, never one per keystroke or per command: that the plugin uses the shell of an earlier build (information), that the document is of a newer format and the plugin needs an update, that the jar does not answer and there is no shell, or that the listing of a project's commands failed later (warnings). Each has an action that opens the setting. The document's members the plugin does not know are ignored (as before). The global options the plugin gives every command are taken from the document's own options: of --plain-output and --non-interactive, those it lists; both when the document has no options member, has not been read yet, or cannot be read. The start class stays the one the manifest names.

Setting (GrailsCommandLineSettings). Settings ▸ Languages & Frameworks ▸ Grails has a new choice, Command line of Grails 9 projects: Automatic (the default, as above), Grails 9 command line (whatever the jar answers; it is still asked, for the global options and the completion) or Grails shell (the jar is not asked; without a resolved shell no command runs). It applies to the project's applications of Grails 9 and later only, is kept per project in the workspace file (GrailsCommandLine state), and a change drops the cached command lists. README.md describes it.

Running commands (Grails9CommandExecutor). Commands of a Grails 9 project on the Grails 9 command line (Run Grails Command, the New Controller/Service/... actions, generate-*, a Grails run configuration with any command but run-app) start the all jar with the global options above and -XX:TieredStopAtLevel=1 (what the distribution's start scripts give a command). The class started is the one the Main-Class attribute of the jar's manifest names, read each time a command starts, as the Grails 9 wrapper starts it: the start class has moved from org.apache.grails.cli.GrailsCli to org.apache.grails.forge.cli.GrailsCli in apache/grails-core#17114 (the jar built from it now names the latter), and reading the manifest keeps the plugin working across that move and any later one. org.apache.grails.forge.cli.GrailsCli is used only for a jar whose manifest names no start class (or cannot be read). The shell's spellings that Grails 9 refuses are translated: an environment or -D options in front of the command (prod war, -Dx=y run-app) move behind it, the environment as -Dgrails.env=production (upgrade note 43). Grails3InstallationCommandExecutor, whose SDK layout Grails 9 does not have, claims a Grails 9 project only when its commands run in the shell.

Command list (Grails9HelpDocument, Grails9CommandCatalog, Grails9CommandProvider). Completion in Run Grails Command offers the names and aliases grails help --json lists in the project: the built-in commands the project's record allows, the commands of the application and its plugins that grailsCommandCatalog listed, and the scripts. Only a jar that answered format 1 is asked in the project. The document (format 1) is cached per project and asked again only when it can be out of date: when one of the files the answer depends on changes (.grails/project.yml, .grails/forge.lock.yml, .grails/cache/command-catalog.json, grails-forge-cli.yml, grails-cli.yml, gradle.properties, src/main/scripts, grails-app/commands), when the command line's class path or version changes, when another command line is chosen, and after a Gradle reload or a recomputation of the Grails applications. A failed listing is cached as empty until then, so a broken command line is not restarted on every keystroke. The event dispatch thread never waits: it gets the document known so far while a newer one is fetched in the background; completion, which runs off it, waits cancellably. The dialog prefetches the document when it opens. A run of help --json takes about 0.4 s.

Run configuration (Grails9RunApp). For every Grails 9 project, whichever command line runs its other commands, run-app of a Grails run configuration runs the Gradle task bootRun through the IDE's Gradle support, in a run of its own (named after the configuration), with Run and Debug both supported; the run configuration hands it over before it asks for an executor, so a project whose commands have nothing to run in still runs its application. I chose bootRun over starting the CLI's run-app:

  • Debugging: the IDE's Gradle support attaches the debugger to the JVM bootRun forks, on a port of its choosing. Through the CLI it would need run-app --debug-jvm, a fixed port 5005 that suspends, and the plugin's current debug path for the shell (GRAILS_FORK_OPTS) is not read by Grails 9.
  • Stop: cancelling the Gradle run ends the application; through the CLI there is one more process (CLI, wrapper, Gradle, application) between the Stop button and the application.
  • Run record: the CLI's run-app writes .grails/run/app.json for grails stop-app. bootRun writes none, so grails stop-app in a terminal does not stop an application the IDE started, which is what the Grails guide says for ./gradlew bootRun; the IDE's Stop is the way to stop it.
  • Note 51 and the plugin's own plan (IMPROVEMENT-PLAN.md 2.6) point the IDE at the Gradle tasks for build commands.

The options of run-app that bootRun has an equivalent for are given as the command line gives them: the environment (default development) as -Dgrails.env, --port/--host (also with one dash or =) as -Dgrails.server.port/-Dgrails.server.address, -D/-P as they are, and everything after -- to Gradle. --debug-jvm is dropped (use Debug). Options only the CLI has (--https, --detach, --foreground, --ready-timeout, --query-tail, --verbose) and VM options (which would reach the Gradle daemon, not the application) are refused with a message that says what to do instead. "Launch browser" is kept: a project-level ExecutionListener attaches the existing browser-launch listener to the Gradle run when the application prints Grails application running at .... A Grails 9 project is runnable (GrailsRunConfigurationType.isRunnable) even when neither command line could be resolved, since bootRun needs neither.

Tests of the application. The Grails test configuration producer no longer offers its test-app configuration for a Grails 9 project, whichever command line it has (the Grails 9 command line has no intellij-command-proxy to run it through); the IDE's Gradle test runner runs those tests, as for any Gradle project.

Detection. Grails 9 projects are recognised as before, from the Grails Gradle plugin the import finds (the plugin ids are unchanged in Grails 9) and their grails-app directory, which every application type Grails 9 generates has. .grails/project.yml is recognised (Grails9Projects) as the record of a Grails 9 project, and marks the root of a Grails project in the scan that reports Grails roots whose Gradle import failed (GrailsGradleSyncStatus), as the Grails 9 command line treats it. It does not switch the version (see above).

The new-project wizard (hosted Forge API) is not changed. README.md and IMPROVEMENT-PLAN.md (2.6) describe the Grails 9 behaviour, the fallback and the setting.

How it was tested

New tests, in the plugin's test framework:

  • Grails9CommandLinesTest (13): the choice of the command line, with real jars the test writes and the plugin starts as a process (FakeGrailsCommandLines, whose start class is a small class of the test sources): a jar that answers format 1 is the command line (asked once, with --plain-output --non-interactive help --json and GRAILS_PREFERRED_SHELL=forge), with its completion and no notice; one that answers format 2 stays the command line, without completion, with the contract's global options and one warning; a stand-in for the earlier builds (exit 2 at once with GRAILS_PREFERRED_SHELL=forge, two minutes without it, which also shows the variable is passed) gives way to the shell, with the shell's commands and one notice naming grails-shell-cli; one that does not answer within the time (2 s in the test) gives way to the shell; without a shell, a jar that is not the command line keeps it without completion; one notice for each jar however often executors, completion and listings are asked across two applications, and another for another jar; a jar is asked once until it is replaced; the event dispatch thread does not wait for a jar that takes 3 s; the global options from the document (both, only --plain-output, none listed); the setting forcing the shell (the jar not asked) and the command line (for a jar that does not answer); the setting leaving Grails 8 alone; run-app stays bootRun with nothing to run commands in.
  • GrailsCommandLineSettingsTest (4): automatic by default, kept through serialization, an unknown stored value read as automatic, a change told once.
  • Grails9ProjectsTest (7): the version switch by the major version of grailsVersion (snapshots, milestones and 10.x included; 8.x, 7.x and malformed versions excluded); the .grails/project.yml record and what is not one; a Grails 8 project with a record keeps the shell; a Grails 9 project without one gets the Grails 9 path.
  • Grails9CommandExecutorTest (8): which executor a Grails 9 and a Grails 8 project get, and a Grails 9 project with a shell and no command line jar on disk gets the shell; the Java parameters (the all jar alone on the class path, no grails-rt, --plain-output --non-interactive first, -XX:TieredStopAtLevel=1, the project as working directory, the command's VM options); the start class read from the manifest of jars the test writes (the new class name, the earlier one, the first jar that names one, and the fallback for a jar without Main-Class, a file that is no jar and a missing file); an environment and properties in front of the command moved behind it; an unresolved command line reported while the project stays runnable.
  • Grails9RunAppTest (10): the bootRun arguments for run-app and its options, the refused options and VM options, and the Gradle run settings.
  • Grails9HelpDocumentTest (9): two documents grails help --json wrote, recorded in a web application created with grails create-app com.example.shop by the command line built from Make Grails Forge the one generator and grails the one command line grails-core#17114 (9.0.0-SNAPSHOT), before and after ./gradlew grailsCommandCatalog (plugin/testdata/grails9/help-json, the project path replaced by /home/me/shop; the second keeps the commands but not their options, to keep it small); the refusal of another format; a later format told apart from output that is no document; the options of the command line itself; members the reader does not know.
  • Grails9CommandCatalogTest (11): completion from the document; the command line asked once while nothing changes, and again after a change to command-catalog.json, a script, the record, the command line's version, the choice of the command line, a Gradle reload or a recomputation of the applications; a failed listing kept, with one notice over two failed listings; a listing of another format not read; the event dispatch thread answered at once with the document known so far; no listing for a Grails 8 project.
  • GrailsCustomFoldersConfigurableUiTest (+1): the settings page opens on the stored choice, offers the three, is modified by another choice and stores it.
  • GrailsGradleSyncStatusTest (+1) and GrailsRunConfigurationProducerTest (+1): the record marks a blocked Grails root; no Grails test configuration for a Grails 9 project. Both fail with the change reverted.
  • GradleApacheGrailsImportingTest (+3): a real Gradle 9.8.0 import with the Grails Gradle plugin 8.0.0-RC2. All three use the grailsVersion of a Grails 9 version that is never published, against a file repository in the project: with the command line only, the model holds exactly the all jar (the stand-in POM names a dependency the repository does not have, so a transitive resolution would fail) and no shell, and nothing is reported; with the command line and a shell, the model holds both, the stand-in jar (no jar at all) answers nothing and the shell executor is chosen; with neither, the Build tool window reports "Grails command line could not be resolved" while the project stays runnable. No test resolves a published Grails 9 build. The follow-up is an import test pinned to the first published Grails 9 milestone, to add when that milestone exists (IMPROVEMENT-PLAN.md 2.6); a check against the Grails 9 snapshots, if wanted earlier, belongs on a schedule rather than in every build.

Runs:

  • The 170 tests of the affected classes (the ones above with GrailsRunTargetCompletionTest, GrailsRunConfigurationTypeTest, GrailsCommandLineExecutorTest and GrailsCustomFoldersConfigurableTest) pass.
  • ./gradlew test: 1568 tests in 251 classes, 0 failures, 0 errors, 0 skipped, including the Gradle import tests for Grails 3.3.1, Grails 6 and Grails 8.0.0-RC2. That run still had an import test of the published 9.0.0-SNAPSHOT, which this pull request no longer has, so the suite now has 1567.
  • ./gradlew rat passes.

By hand, against the two real jars:

  • The grails-cli-9.0.0-20261123.015441-38-all.jar of the ASF snapshot repository (from before Make Grails Forge the one generator and grails the one command line grails-core#17114; Main-Class: org.apache.grails.cli.DelegatingShellApplication), started with --plain-output --non-interactive help --json: without GRAILS_PREFERRED_SHELL it ends with exit code 1 and no JSON after 63 s in an empty directory and after 103 s in a Grails 9 application (where it downloaded a Gradle distribution and started Gradle); with GRAILS_PREFERRED_SHELL=forge it ends in 1 s with exit code 2 and "Unknown options: '--plain-output', '--non-interactive', 'help', '--json'". The plugin's code (the probe and the choice, run against the jar) classifies it in 1.1 s as not the command line and picks the shell executor when the shell is resolved, and the Grails 9 executor without completion when it is not.
  • The all jar built from Make Grails Forge the one generator and grails the one command line grails-core#17114 (Main-Class: org.apache.grails.forge.cli.GrailsCli): it answers format 1 in under a second in an empty directory and in an application it created (create-app com.example.shop), with options listing -h/--help, --non-interactive, --plain-output, -x/--stacktrace, -v/--verbose and -V/--version, with or without GRAILS_PREFERRED_SHELL=forge. The plugin's code classifies it in 0.43 s as the command line and starts commands with --plain-output --non-interactive.
  • From the earlier round, with the all jar of Make Grails Forge the one generator and grails the one command line grails-core#17114 (then still naming org.apache.grails.cli.GrailsCli): create-controller com.example.Book, started as the plugin starts it, writes BookController.groovy and BookControllerSpec.groovy; prod war with the environment in front ends with exit code 2, which is why the plugin moves it behind the command; ./gradlew bootRun -Dgrails.env=development -Dgrails.server.port=18080, the Gradle arguments the plugin gives for run-app --port 18080, starts the application on port 18080 (HTTP 200), which prints the line the browser launcher looks for, and cancelling the Gradle run ended it.

Not run: the Plugin Verifier, the Community Edition tests (testIdeCe) and the sandbox IDE.

What is not done

  • The plugin was not run in a sandbox IDE (runIde), and Debug of bootRun, Stop, the browser launch, the completion in the dialog, the notifications and the settings page were not exercised interactively. The hand-off to the Gradle run (ExternalSystemUtil.runTask) is not covered by a test; its settings are. That the run configuration hands run-app of a Grails 9 project to bootRun before it looks for an executor is covered through Grails9RunApp.runsAsBootRun and isRunnable, not through getState/checkConfiguration themselves.
  • No command was run in the shell of a real pre-#17114 snapshot through the plugin, and no test imports a published Grails 9 build: the import tests use stand-in jars, and the real snapshot jar was classified by hand (above). Running the shell is the Grails 8 path, which is unchanged.
  • No Grails 9 milestone is published yet. An import test pinned to the first published one is the follow-up, to add when it exists (IMPROVEMENT-PLAN.md 2.6); a check against the snapshots, if wanted earlier, belongs on a schedule rather than in every build.
  • test-app typed into Run Grails Command or a Grails run configuration for a Grails 9 project on the command line runs through it (gradlew testApp) as plain console output, without the test tree.
  • Completion does not offer the subcommands of feature and project, option names, or descriptions, which help --json has; nor does the plugin offer to run grailsCommandCatalog when the document says the application's commands are not listed yet.
  • A Grails 9 SDK configured by hand (the Grails SDK setting) is used only for a project whose commands run in the shell; the command line comes from the Gradle import only.
  • bootRun is given no JVM options of the run configuration; they belong to jvmArgs of bootRun in build.gradle.

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.45329% with 206 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.8460%. Comparing base (45f8598) to head (f40d400).

Files with missing lines Patch % Lines
.../tooling/builder/GrailsModuleModelBuilderImpl.java 0.0000% 29 Missing ⚠️
...ntellij/plugin/commands/Grails9CommandCatalog.java 69.5122% 15 Missing and 10 partials ⚠️
.../intellij/plugin/commands/Grails9CommandLines.java 75.4902% 8 Missing and 17 partials ⚠️
...ellij/plugin/commands/Grails9CommandLineProbe.java 62.0690% 10 Missing and 12 partials ⚠️
...ils/intellij/plugin/runner/impl/Grails9RunApp.java 69.0141% 14 Missing and 8 partials ⚠️
...lij/plugin/runner/impl/Grails9CommandExecutor.java 84.6154% 2 Missing and 12 partials ⚠️
.../intellij/plugin/commands/Grails9HelpDocument.java 85.2273% 0 Missing and 13 partials ⚠️
...ils/intellij/plugin/ui/GrailsRunCommandDialog.java 0.0000% 10 Missing ⚠️
...intellij/plugin/runner/GrailsRunConfiguration.java 0.0000% 6 Missing ⚠️
...ugin/runner/impl/Grails9RunAppBrowserLauncher.java 0.0000% 6 Missing ⚠️
... and 13 more
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                 main       #477        +/-   ##
==================================================
+ Coverage     52.2649%   52.8460%   +0.5811%     
- Complexity        558        568        +10     
==================================================
  Files             717        729        +12     
  Lines           25432      26072       +640     
  Branches         6645       6801       +156     
==================================================
+ Hits            13292      13778       +486     
- Misses           9092       9142        +50     
- Partials         3048       3152       +104     
Files with missing lines Coverage Δ
.../plugin/gradle/GrailsProjectResolverExtension.java 64.2857% <100.0000%> (+2.7472%) ⬆️
...llij/plugin/runner/GrailsRunConfigurationType.java 66.6667% <100.0000%> (+3.0303%) ⬆️
.../plugin/structure/impl/Grails3ApplicationBase.java 52.3810% <100.0000%> (+2.3809%) ⬆️
.../lib/gradle/tooling/builder/GrailsCommandLine.java 90.9091% <90.9091%> (ø)
...intellij/plugin/gradle/GrailsGradleSyncStatus.java 55.3846% <90.9091%> (+3.3521%) ⬆️
...ugin/runner/impl/Grails3GradleCommandExecutor.java 88.8889% <66.6667%> (+82.6389%) ⬆️
.../intellij/plugin/structure/Grails3Application.java 0.0000% <0.0000%> (ø)
.../tests/runner/GrailsTestConfigurationProducer.java 63.7681% <50.0000%> (-0.4110%) ⬇️
...tellij/plugin/commands/Grails9CommandProvider.java 33.3333% <33.3333%> (ø)
...ils/intellij/plugin/structure/Grails9Projects.java 81.8182% <81.8182%> (ø)
... and 16 more

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Grails 9 publishes no Grails shell. Its one command line replaces the
shell and the Forge CLI, and upgrade note 51 of the Grails guide tells
IDEs what to do instead: run the build commands as Gradle tasks, start
the command line of org.apache.grails:grails-cli with --plain-output
--non-interactive, and ask help --json for the commands of a project
rather than carry a list. The plugin started org.grails.cli.GrailsCli of
grails-shell-cli for every Gradle project and offered a fixed list of
shell commands, so a Grails 9 project had no Grails commands and no
Grails run configuration.

For a project whose grailsVersion has a major version of 9 or more, the
Gradle import resolves the all jar of org.apache.grails:grails-cli, not
transitively: that jar holds the command line and everything it needs,
where the plain jar would bring the Gradle Tooling API, which Maven
Central does not have. It also resolves the Grails shell of the version,
which the builds of Grails 9 from before its command line still publish.
That neither can be resolved is reported in the Build tool window.
Projects of Grails 7 and 8 keep the shell.

Which of the two runs the commands is decided by what the jar answers,
not by the version, so that the plugin can be released before Grails
9.0 and used with its snapshots and milestones. The jar is started
once for each jar on disk, off the event dispatch thread and for at most
30 seconds, with --plain-output --non-interactive help --json and
GRAILS_PREFERRED_SHELL=forge, which the command line of Grails 9 does
not read and which makes the start class of an earlier build refuse at
once instead of starting the shell. A document of format 1 makes it the
command line. A document of another format keeps it without completion,
as does a jar that does not answer when no shell was resolved; otherwise
the shell runs the commands, as for Grails 8. Every outcome but format 1
gives one notification for each project and jar. A setting of the
project on the Grails settings page chooses automatic, the Grails 9
command line or the Grails shell.

Commands run in the jar of the command line with those of --plain-output
and --non-interactive that its document lists as its options, and with
an environment or system properties typed in front of the command moved
behind it, since Grails 9 refuses them there. The class started is the
one the Main-Class attribute of the jar's manifest names, as the Grails
wrapper of Grails 9 starts it, so that the plugin does not change when
the class moves; org.apache.grails.forge.cli.GrailsCli is the fallback
for a jar that names none. Completion offers the commands help --json
lists in the project; the document is kept per project and asked again
only when a file it depends on, the command line, the choice of it or
the Gradle import changes, and the event dispatch thread never waits for
it.

run-app of a Grails run configuration of every Grails 9 project runs the
Gradle task bootRun through the IDE's Gradle support, which debugs and
stops the application as it does every Gradle task, whichever command
line runs the other commands; the run-app options that bootRun has an
equivalent for are mapped as the command line maps them, and the others
are refused with a message. The Grails test configuration producer
leaves the tests of a Grails 9 project to the Gradle test runner, and
.grails/project.yml, the record of a project Grails 9 generated, marks a
Grails root in the scan for roots whose Gradle import failed.

The Grails 9 import tests use stand-in jars from a file repository in
the test project, so the build does not depend on a published Grails 9.
An import test pinned to the first published Grails 9 milestone is the
follow-up, to add when that milestone exists.
@jdaugherty
jdaugherty marked this pull request as ready for review November 23, 2026 23:04
@jdaugherty

Copy link
Copy Markdown
Contributor Author

This "should" work without the forge rewrite in place, but the expectation is we'll publish this prior to the release of 9.

…es it

An environment in front of a command, as the Grails shell took it, was moved behind the name of every command: prod dbm-update became dbm-update -Dgrails.env=production. The Grails 9 command line reads -Dgrails.env after the name only for its own commands. A command of the application or of a plugin is given everything after its name as its arguments, so it ran in development with the option as one of them, which for a command that changes a database is the wrong database.

The environment and the system properties typed in front of a command now go where the command takes them. A command of the command line itself still takes them after its name. A command of the application or of a plugin is run with run-command, which takes them in front of the name of the command it runs, as the Grails guide gives for another environment: run-command -Dgrails.env=production dbm-update. run-command typed by the user gets them in front of that name too, unless it names an environment there itself. A script of the application keeps them after its name, where it reads them.

Which kind a command is comes from the document of help --json, which now also reads the registration of a command to tell a script. A name the document does not list is run with run-command, which runs a command the build has listed since and refuses any other name before anything runs. When the document lists no command at all, a command with an environment in front of it is refused with a message that names both forms to type, since a guess could run it in development. A command with nothing in front of it is run as typed and the document is not asked.
The Grails run configuration of a Grails 9 project ran the Gradle task by its name, bootRun, in the directory of the application. A name selects the task of that name in every project below the directory, so for a root application whose build has other applications below it, run-app started those as well.

The task is now named by the path of the Gradle project of the application, as the Grails 9 command line names the tasks of the project it is run in: :bootRun for the root project and :path:bootRun for a project below it. The path is the one the Gradle import recorded for the module of the application, which Grails3Application now answers. An application whose module has no recorded path keeps the name alone.
What an application or a plugin adds to the grails command line is now a tool,
and the document of help --json says more of it: startsApplication, deprecated
for a tool that implements a deprecated type or lives in grails-app/commands,
and deprecatedNames on the commands of grails itself. Grails9HelpDocument reads
these members and falls back to defaults where a build of Grails 9 from before
does not write them, so its documents and a target or registration the plugin
does not know are still read.

An environment typed in front of a tool of the application or of a plugin is
now given through run-tool, which does not warn. run-command, still accepted,
is kept as it is typed. Completion no longer offers a deprecated alias such as
run-command, and offers create-tool, which the document lists in place of
create-command. The messages and the README speak of tools where they mean what
applications and plugins add; built-in commands stay commands.

The recorded help --json fixtures have the new shape, one of the earlier shape
is kept, and the document and executor tests cover both.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant