Skip to content

Make Grails Forge the one generator and grails the one command line - #17114

Open
jdaugherty wants to merge 755 commits into
apache:10.0.xfrom
jdaugherty:feat/16348-one-generator
Open

jdaugherty wants to merge 755 commits into
apache:10.0.xfrom
jdaugherty:feat/16348-one-generator

Conversation

@jdaugherty

@jdaugherty jdaugherty commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

One generator, one command line

Retargeted to 10.0.x on 2026-12-02. The command line first ships in Grails 10; Grails 9 keeps the Grails shell and the profiles, as Grails 7 and 8 do. The feature packs are for [10.0.0,11.0.0), the command line works with projects of Grails 10 and later, and the upgrade notes of this change are notes 3 to 42 of the Grails 10 guide.

Implements #16348 for Grails 10: Grails Forge is the only application generator, grails is the one command line, and the Grails shell and the profiles are removed. The design, with what 10.0 ships, its limits and the decisions behind it, is grails-forge/FORGE-CLI-DESIGN.md; users read the guide, which the design links to.

Fixes #14932
Fixes #14187
Fixes #14872

Requires apache/grails-plugins-metadata#326. That open pull request has the indexer record the feature pack of a plugin version in the plugin index (grails-plugins-index.json), which is what this command line reads to know which plugins bring a feature pack. Until it is merged and the index is written again, the index has no pack entries: a feature of a plugin cannot be selected by its name with --features, and plugin-info cannot name the feature a plugin is added with. The features of Grails itself, a pack named by its coordinates or by a directory, and list-plugins/plugin-info for everything else do not depend on it. The two are to be merged together, the metadata change after this one.

Goes with apache/grails-intellij-plugin#477, an open pull request. The released IntelliJ plugin starts org.grails.cli.GrailsCli of grails-shell-cli and offers a fixed list of shell commands, and Grails 10 publishes no shell: without that pull request a Grails 10 project has no Grails commands and no Grails run configuration in IntelliJ IDEA. It switches a project of Grails 10 or later to this command line: it starts the Main-Class of the grails-cli jar (org.apache.grails.forge.cli.GrailsCli), takes the commands from help --json, gives the environment where each command takes it, and runs run-app as the Gradle task bootRun of the module; projects of Grails 7, 8 and 9 keep the shell. The contract it follows is upgrade note 23. It is to be released alongside Grails 10.0.0.

What it implements

  • One command line. grails is the former Forge CLI, extended to do what the shell did in a project. grails-shell-cli, the seven profile artifacts, -t/--type and GRAILS_PREFERRED_SHELL are gone.
  • How Gradle is run. A command line that runs one command starts the project's Gradle wrapper as a process, so Gradle has the terminal. The interactive console runs its builds through the Gradle Tooling API on one connection it keeps (a further build takes about 50 ms there instead of about 350), in plain text, with Ctrl-C cancelling the build and returning to the prompt. grails gradle ..., run-app --detach and shell always use the wrapper. GRAILS_GRADLE_RUNNER (auto, process, tooling-api) overrides the choice and GRAILS_CLI_DIAGNOSTICS=true says which way each command ran and why.
  • Application types, feature packs and presets. create-app, create-restapi, create-plugin, create-web-plugin and the new create-rest-api-plugin. Most features are declarative feature packs (61 bundled); a plugin can ship its own in src/main/forge, checked by checkForgePack and forgePackTest. New among the bundled ones: grails-publish for the plugin types, which sets a plugin up for the Grails Publish Gradle plugin. A project of each of the five types is assembled by Gradle in the tests; the JSON and markup views Gradle plugins now build a project that has no grails-app/views, which a new REST API plugin is.
  • What the pack of a plugin can say. Everything a pack of Grails says to contribute: dependencies in every scope (buildscript among them), platforms, build plugins, build properties, extensions and blocks, configuration, files, readme sections, and conditions (when) on the type of the application, its features, options, Java version and the pack's own parameters. parameters are options of a feature, set with --feature-option FEATURE.NAME=VALUE on the create commands and on feature add, read by the templates and recorded with the project. instructions are printed once the application is created or the feature added, as plain text. artefacts give the command line commands that create classes: grails create-<name> <Class> writes a class, and optionally its test, from a token template the feature put under src/main/templates/features/<feature>/ of the application, where the team can edit it; nothing of a template is run. Reserved to Grails' own packs: selecting a feature without it being named (default, adds, reliesOn), hiding it (visible), its place among the features (order), joining an exclusive group of Grails such as database-driver, and the versions this release of Grails knows (versionOfForge and its kin). The reasons: a pack comes from somebody other than the user and the framework, so it is used only when it is named and it only adds; and the same pack has to generate the same application with every release of the command line. The guide has the table ("What a Pack Can Do").
  • Presets. A pack of kind: preset names one application type, gives the create options their defaults and asks for features, and takes the place of a profile of one's own: grails create-restapi shop --preset com.acme:acme-preset:1.0.0.
  • The BOM of a generated application follows its data choice: grails-bom (Hibernate 5), grails-hibernate7-bom, or grails-neo4j-bom for GORM for Neo4j, whose driver version grails-bom cannot hold. Combinations no BOM covers (GORM for Neo4j with Hibernate 7 or Micronaut) are refused with the reason.
  • cache-ehcache gives Ehcache 3 through JCache with released versions the BOM manages (org.ehcache:ehcache, its Jakarta EE variant through requireCapability), a grails-app/conf/ehcache.xml and a grailsCacheManager of the application in resources.groovy; it replaces org.grails.plugins:cache-ehcache, whose only release for this line, 5.0.0-RC1, Grails 10 does not load. The Hibernate second-level cache through JCache is documented in the guide. Feature packs can now require a capability of a dependency.
  • grails-bom manages the MCP Java SDK (io.modelcontextprotocol.sdk:mcp-bom) at the version Spring AI depends on, 2.2.0 with Spring AI 2.1.0, so applications using Spring AI's MCP support and the command line share one SDK. No BOM managed it before: neither Spring Boot's nor Spring AI's lists it. validateMcpSdkVersion fails the BOM build when a Spring AI bump needs another SDK version, and names the version to set.
  • A record of the project. .grails/project.yml, .grails/forge.lock.yml and .grails/baseline/ say how a project was generated and by which build of the generator. project show prints the command that makes the same application again; project regenerate --diff lists what differs from what was generated. An interrupted change is ended file by file, never over a later edit. --json gives a program each result with an outcome and a reason.
  • Features after creation. feature add [--replace] [--dry-run] [--diff] changes a project later with a three-way merge of what was generated, what the feature generates and what the project has; all files are written or none. It adds a feature of Grails, and the feature of a plugin's pack by the coordinates of the plugin (grails feature add com.acme:acme-audit-grails:2.3.0), by a directory (NAME --feature-pack-dir DIR) or by a name of a feature catalog, with the checks and options of the create commands; a preset, and another version of a pack the application has, are refused. feature list says what a project has and what can be added. Three commands look without changing anything: feature find TEXT lists the features that have a text in their name, title, description or category; feature show FEATURE (also feature info) says what a feature is for, what it requires and replaces, the commands it gives, and the files and build lines it contributes; feature diff FEATURE... writes the unified diff feature add would apply. The three take the pack options of feature add, so they also speak of a feature of a plugin's pack the application does not have yet. Outside a project, or with --type, they speak of a new application of that type.
  • feature add after an upgrade. project migrate writes the record of an application of Grails 7, 8 or 9 (or of one Grails 10 did not generate) together with a baseline: the files Grails 10 generates for the type, options and features it found in the project, read as text. feature add then works in the upgraded application, taking what the application has otherwise for the user's change. Because its files were never the generated ones, three things are done for such an application only: a file the baseline has and the application lacks (the README.md of a shell-created application) is left out and the feature added without it; the lines a feature adds to build.gradle are placed by the order of a Gradle build file where the merge finds no place for them (dependencies at the end of the dependencies block, apply plugin: and apply from: after the last such line, a plugin id at the end of the plugins block or in a new one after buildscript, an entry at the end of a list written one entry per line, and the dependency of a default the feature replaces is taken out where the file has that very line); a setting it adds goes into a YAML document of its own, unless the file already sets it for an environment (environments.NAME), which is then a conflict, and a value it changes is replaced where the file has it, when the key is there once and still has the generated value; README lines go to the end of the file; and a BootStrap.groovy that is exactly what an earlier version generated becomes the file this version generates with the feature. What still conflicts, and writes nothing: a configuration value both the user and the feature changed, a key the file sets twice or the feature removes, lines a feature adds to a class the user changed, and build file lines of any other kind. On the test fixtures all ten features tried are added as they are to an application Grails Forge 8.0.0 generated, to one of Forge 7.0.9 and to one the Grails shell of 8.0.0 created; a generated application whose build file was rearranged, migrated and given three features is compiled by Gradle in the tests. Where the type had to be assumed, or Grails 10 creates no application from what was found, the record is written without a baseline and project migrate --force with the missing option writes it with one. project migrate also moves the record of an earlier Grails 10 version.
  • grails project health checks a project's files offline (Grails, Gradle and Java versions, both wrappers and the Gradle checksum, removed or deprecated dependencies, the record, Git files, the list of commands, leftovers of earlier versions, agent skills). Each finding has a stable id, a level (error, warning, advice), the fix and the upgrade note; --strict also fails on a warning and --json is for automation. It runs in a project still on Grails 7, 8 or 9, as project migrate does.
  • Why "tool". What an application or a plugin adds to the command line was called a command in Grails 9 and in the earlier builds of this branch. It is renamed, and every type, task, folder and file is settled on Tool (ApplicationTool, StandaloneTool, create-tool, run-tool, runTool, grailsToolCatalog), for two reasons. A command object already means something else in Grails, the object a controller action binds and validates a request into, and "command" for both was a standing source of confusion. And with an MCP server now part of grails (below), another word was needed for what an agent can call: "tool" is what the Model Context Protocol itself calls these, so a tool of the application is a tool of grails mcp under the same name.
  • What an application or a plugin adds to grails is a tool, and the folder of its source decides how it runs. grails keeps the word command for its own (create-app, run-app, feature add, help). Tools are run by their names, as the commands of plugins were in Grails 9: grails dbm-update, grails s2-quickstart com.example User Role, grails generate-all Book. A tool in src/cli (ApplicationTool) is compiled against the classes of the project and run by the build with the Gradle task runTool, with the application started around it unless it declares boolean startsApplication = false. A tool in src/standalone (StandaloneTool) is compiled against the tool API alone and run by the command line as a plain Java process, without Gradle and without the application, also while the project does not compile. Nothing of either folder is on the class path of the application as it runs or is packaged, which is why the cli tier exists, and grailsCli is no longer on the compile class path of the application. Every build that compiles the project lists the tools (grailsToolCatalog, into .grails/cache/tool-catalog.json); a name the command line does not know yet has the build list them once and try again. grails help NAME describes one without running anything. A standalone tool runs from a class path every build writes down (.grails/cache/standalone-tools.json, by a task that does not compile the application); a record that is out of date is written again by one build before the process starts, so old classes never run, and the files it names are held to the rules the Gradle wrapper of a project is held to (owned by the user, not writable by others, below the build, the Gradle user home or the local Maven repository). run-tool NAME runs any tool with Gradle. See the three tables below.
  • Every Grails plugin with tools publishes its tools in companions. <artifact>-cli (from src/cli, src/standalone and the deprecated grails-app/commands) and <artifact>-cli-standalone (from src/standalone, never depending on the plugin, published when the plugin has such a tool), without applying grails-plugin-cli. A plugin whose tools are all standalone publishes a -cli without classes that depends on its -cli-standalone, so grailsCli "org.apache.grails:grails-scaffolding-cli" keeps working. An application gets both by depending on the plugin, in the scopes grailsCli and grailsCliStandalone; grailsCliStandalone alone takes the standalone tools of a plugin without the plugin.
  • The commands of Grails 9 keep working; the bridge for those of Grails 7 is removed. grails-app/commands is compiled with src/cli and runs as before, under the names the commands had (a class of the deprecated types named ExportTool is still export-tool, and a command is found by the name it gives itself, as in Grails 9), ApplicationCommand and GrailsApplicationCommand are deprecated subtypes of ApplicationTool, and run-command, runCommand, run-script, runScript, runScriptCommand and the scripts in src/main/scripts are deprecated; each keeps working and warns once, naming tools. create-command is refused in favour of create-tool [--standalone]. grails-core-cli-legacy, grails.dev.commands.*, grailsCliLegacy and legacyCommandSupport are gone.
  • The framework's scripts are tools. The Spring Security scripts (s2-quickstart, s2-create-*, s2-create-acl-domains, init-oauth2, s2ui-*), query-tail and the scaffolding scripts are compiled tools, and the Quartz and Geb scripts are replaced by create-job and create-functional-test. The scaffolding tools and six of the Spring Security tools are standalone tools in -cli-standalone companions; s2-quickstart and query-tail are tools of src/cli that do not start the application; the dbm- tools start it. generate-all, generate-controller and generate-views generate what the rest-api profile generated in a REST API application or plugin that has the scaffolding feature (a REST controller, its data service, their specs, and the JSON views index.gson, show.gson and _<name>.gson); they choose JSON views from the features of the project's record (views-json without gsp), or from its views where it has no record, and --views=json|gsp decides it explicitly. Scripts are deprecated: the scripts a project or a third-party plugin has still run, with a warning said once, and the command line creates no new one (create-script is removed in favour of create-tool). s2-quickstart writes all of its files or none: it checks everything first (settings that are already there, class files that exist, where the bean of the password encoder listener goes, whether the configuration can be written) and refuses before it creates anything, unless --force.
  • Tools declare what they take and do. @ToolOption and @ToolParameter on the fields of a tool (or on the class, for a tool that reads its command line itself, where type = 'integer' and choices say that a value is a whole number or one of a few words; an @AnnotationCollector shares a set), @ToolHints for what running it does (readOnlyHint, destructiveHint, idempotentHint, openWorldHint, the vocabulary of MCP and of Spring AI's @McpTool), boolean readsInput = true for a tool that asks what is typed, and executionContext.result for a result as data. help NAME, completion, help --json, IDEs and grails mcp read the declarations. A tool that declares an option or a parameter is held to them: anything else is refused with exit code 2 before Gradle or the application starts, and grails NAME --help shows its help. The compiler checks the declarations, and warns about a tool without a description, one that reads arguments it does not declare, or one that reads what is typed without saying so; project health advises the same (tools.description-missing, tools.arguments-undeclared, tools.hints-missing). create-tool writes a tool that declares all of it. A tool that declares nothing runs as before.
  • The tools of Grails declare theirs, under the names their options always had, with hints: the 31 dbm-* tools of each Hibernate line, schema-export, the scaffolding and Spring Security tools, query-tail, generate-open-api. FrameworkToolsCompleteSpec fails the build when a tool of the framework lacks a description, hints or declarations. Twelve say that they change nothing, so grails mcp --read-only offers them: query-tail, url-mappings-report, seven of the dbm-*-sql tools, dbm-validate, dbm-status and dbm-list-locks. A spec holds each of the dbm ones to that against a database: the seven change nothing at all; the last three never touch the schema or the data of the application, and in a database Liquibase has not used yet they create its two empty bookkeeping tables, as any first use of the plugin does.
  • grails mcp: the command line is an MCP server. claude mcp add grails -- grails mcp, or ./grailsw mcp in a .mcp.json the team commits (the optional Forge feature grails-mcp writes it). It serves the Model Context Protocol, revision 2026-07-28, on its standard input and output through the official MCP Java SDK's modern server; it binds no socket. An agent gets, as MCP tools, every command of the directory that makes sense without a terminal (the create commands, feature_*, plugin_*, project_*, the code generation commands, compile, test-app, run-app/stop-app, run-tool, and the rest: 39 in a new web application) and every tool of the application and its plugins, with no opt-in, with input schemas made from their declarations. The tool list is help --json of the directory, projected: the same document help, completion and the IntelliJ plugin read. refresh_tools has the build list the tools again, and the list a client holds is updated when the build lists a new tool. Resources: grails://commands (the help --json document, with diagnostics that say why something is not offered), grails://tools/{name}, grails://project, grails://project/health, and the log of each call.
  • One program, two front ends. The server is the grails process. Each call runs one grails --plain-output --non-interactive command line in it, as interactive mode runs a line, with one Gradle Tooling API connection and the project generator kept for the session. Builds run in Gradle, and tools in Gradle or in a process of their own, exactly as at the terminal (see the table below): no class of the project or of its dependencies is loaded in the server. Calls run in three lanes (one build, one generator call, four others at a time), report progress, and can be cancelled: a cancelled build is stopped, and a cancelled generator or code generation call finishes its files and its result is dropped. Long output is shortened and the whole of it kept in .grails/run/mcp; JSON documents and the result a tool sets are structured content. A report is a result and not an error: project_regenerate that finds changed files, project_health with findings and a dry run of feature_add that finds conflicts end with exit code 1 at the terminal, and over MCP return their document without isError. The tool list stays small (about 69 KB for the 39 tools of a new web application): the whole help --json entry of a tool is the resource grails://tools/NAME, not part of the list. Nothing but the protocol is written to the standard output; when the client closes the input the server stops its builds and ends.
  • What an agent cannot do over MCP. Name a new source of code (no feature pack directory or repository, feature catalog, preset, plugin index, or plugin coordinates as a feature), use what reads typed input (shell, console, a tool that declares readsInput), pass Gradle arguments of its own (gradle is not offered: Gradle has its own tooling), or work in another directory (one server serves one directory). A leading @ of an argument is escaped so that no file is read as arguments, and every call is checked against its schema before anything runs. Hints are passed on only for the commands of Grails, the tools of the application and the tools of Grails' own plugins; a third-party plugin's tools get the protocol's cautious defaults whatever they declare. --read-only offers only the tools that change nothing. The threat model has a row for it.

Where a tool goes

Folder Compiled against How it runs What ships
src/main, grails-app/* the application's dependencies bootRun, the jar or war the application: no tool, no tool-only library
src/cli the project's classes, grailsCli, and src/standalone by the build (runTool), with the application unless startsApplication = false application: nothing; plugin: <artifact>-cli, which depends on the plugin (and on its -cli-standalone when it has one)
src/standalone the tool API and grailsCliStandalone only a plain java process started by grails, no Gradle, never the application; also while the project does not compile application: nothing; plugin: <artifact>-cli-standalone, which never depends on the plugin; when all the tools of a plugin are here, its -cli has no classes and depends on it
grails-app/commands (deprecated) as src/cli as src/cli, with a warning nothing; no longer in the application's jar

What each kind of tool runs with (the same at the terminal, in interactive mode and over grails mcp)

Kind of tool Started by Project compiled first Application started Class path
ApplicationTool in src/cli (the default) the build of the project, Gradle task runTool yes: the project has to compile yes: application context, plugins, data sources, BootStrap the application's classes and run-time dependencies, src/cli, src/standalone, and the scopes grailsCli and grailsCliStandalone
ApplicationTool with boolean startsApplication = false the build, runTool yes no: no context, plugins, data source or BootStrap the same
StandaloneTool in src/standalone grails itself, as a plain java process; no Gradle no: it runs while the project does not compile no, never only src/standalone, the scope grailsCliStandalone and the tool API; nothing of src/main, grails-app or the application's dependencies

None of the three runs in the JVM of grails or of grails mcp, and none is on a class path of the application as it runs or is packaged. The rule for an author: a tool that only reads and writes files of the project goes into src/standalone; every other tool goes into src/cli. grails help NAME, help --json (target, startsApplication) and the description of the tool over MCP say which kind a tool is. Of the tools Grails ships:

Tools
Start the application the dbm-* tools, schema-export, generate-open-api, url-mappings-report, config-report
Run by the build without starting the application s2-quickstart, query-tail
Standalone the nine scaffolding tools (generate-*, create-scaffold-*, install-templates), s2-create-persistent-token, s2-create-role-hierarchy-entry, s2-create-acl-domains, init-oauth2, s2ui-create-challenge-questions, s2ui-override

What is renamed

Grails 9, or an earlier build of this branch Grails 10 The old name
ApplicationCommand, GrailsApplicationCommand ApplicationTool (+ ToolSupport) deprecated subtypes; run as before
StandaloneCommand, StandaloneCommandRunner (earlier 9) StandaloneTool, StandaloneToolRunner renamed
GradleCommand (earlier 9) boolean startsApplication = false removed
grails create-command grails create-tool [--standalone] refused, exit code 2
grails run-command, Gradle runCommand grails run-tool, runTool deprecated, warn once
grails run-script FILE, Gradle runScript, runScriptCommand, scripts in src/main/scripts a tool, run with runTool deprecated, still run, warn once
grailsCommandCatalog, .grails/cache/command-catalog.json (commands) grailsToolCatalog, .grails/cache/tool-catalog.json (tools) renamed
grailsStandaloneCommands, .grails/cache/standalone-commands.json grailsStandaloneTools, .grails/cache/standalone-tools.json renamed
META-INF/grails-commands/<class>.json META-INF/grails-tools/<class>.json renamed
GRAILS_LIST_COMMANDS; health command-catalog.* GRAILS_LIST_TOOLS; tool-catalog.* renamed; GRAILS_LIST_COMMANDS is no longer read
the framework's ...Command classes ...Tool renamed; typed names unchanged
grails-core-cli-legacy, grailsCliLegacy, legacyCommandSupport, grails.dev.commands.* — removed
— scope grailsCliStandalone, artifacts <artifact>-cli-standalone, manifest Grails-Cli-Standalone-Artifact new

What an upgrade asks

Who Has to do Does not have to do
Application author Declare with implementation a grailsCli library that main code uses, or move that code to src/cli. Change grails.dev.commands.* imports (project health names the files). Remove legacyCommandSupport. Move or rename anything: grails-app/commands keeps compiling and running, with warnings.
Plugin author Publish the companions with the plugin: a plugin with tools publishes -cli, and -cli-standalone once it has src/standalone, whether or not it applied grails-plugin-cli; tools under grails-app/commands are in -cli and no longer in the plugin's jar. Tests of a plugin's tools go in src/test-cli. A plugin released for Grails 7 with commands needs a release for Grails 10. Change a companion that has src/cli only, or apply or remove the plugin id. A grailsCli line for a -cli whose tools are all standalone, such as grails-scaffolding-cli, keeps resolving.
CI script Nothing: grails NAME, grails run-script FILE, grails run-command NAME, ./gradlew runScript and ./gradlew runCommand ... keep working (the last four warn). GRAILS_LIST_COMMANDS is no longer read: set GRAILS_LIST_TOOLS. grails create-command fails with exit code 2. —
  • run-app, stop-app, test-app. run-app --detach and run-app in the console return when the application answers on its port (read from application.yml as the application reads it, at the loopback address it binds), and report a failed start at once where the application has the startup progress page; stop-app stops only what run-app started. A plugin, or the application, can add options to run-app: it declares them in META-INF/grails-command-options.json (a name, a description and the application property the option sets), the build lists the valid ones, and run-app shows them in its help and passes each as one system property; no code of the plugin runs in the command line, and properties of the JVM, of Gradle and of where Spring reads its configuration cannot be set that way. run-app --query-tail of Grails Data is declared so. test-app runs every test phase through one Gradle task, testApp; --unit, --integration and --functional select phases, and a test name runs that test in whichever phase has it.
  • The interactive console (grails in a project) has the commands of the directory with completion and history; !program runs a command of the operating system as in the Grails shell; exit and quit end it.
  • Plugins. list-plugins and plugin-info read the plugin index of apache/grails-plugins-metadata (also offline, from a list bundled with the release), and are also commands of a plugin group: plugin list [TEXT], plugin find TEXT and plugin show NAME (also plugin info), the same commands under a second name; every create command line plugin-info suggests creates what it names. GRAILS_PLUGIN_INDEX names another index for every command that reads one.
  • The jars of feature packs are kept. The jar of a plugin that is fetched over https for its feature pack is kept in ~/.grails/forge/packs under its SHA-256, apart from Gradle's cache and the local Maven repository. A kept jar takes the place of a request only when its SHA-256 is known beforehand (the record of the application, --feature-pack-sha256, a catalog) and is hashed again on every read; coordinates alone are always asked of the repository. --offline uses the kept jar, and --refresh fetches again. The directory can be deleted at any time.
  • The Grails wrapper only downloads. Every wrapper, of Grails 7, 8 and 9, starts org.apache.grails.cli.DelegatingShellApplication, the one class of the grails-cli jar it downloads, which starts the Main-Class of that jar, org.apache.grails.forge.cli.GrailsCli of grails-forge-cli. The wrapper of 7, 8 or 9 replaces itself once gradle.properties names Grails 10. The packages of the command line do not overlap org.apache.grails.cli, and both jars have an Automatic-Module-Name. grails-wrapper.jar, which every project commits, is 41.2 KB, and its start scripts refuse a Java older than 21 by name.
  • Completion and machine-readable help. The distribution has bin/grails_completion for bash and zsh; help --json describes every command and option, with values, defaults and rules. Command names can be shortened (cDC, rA, and in lower case ra, sa, cdc); a short form that fits two commands runs neither and names the shortest form of each.
  • Projects before Grails 10 are refused by the commands of a project (exit code 1, one line), except project migrate and project health.
  • Agent skills. The developer skill documents this command line for applications, and the upgrade skill walks an application from Grails 9 to 10 (update-wrapper, project migrate, then project health until --strict passes).

Where to start reading

  • The tour: grails-doc/src/en/guide/commandLine/tour.adoc.
  • What changes for users: the upgrade notes in grails-doc/src/en/guide/upgrading/upgrading100x.adoc; note 27 maps every command line of Grails 9 (the shell, the Forge CLI, plugin commands and scripts) to Grails 10.
  • Agents: grails-doc/src/en/guide/commandLine/mcp.adoc ("Driving Grails from an AI Agent") and, for tool authors, commandLine/creatingTools.adoc, whose every example tool is compiled by CreatingToolsExamplesSpec; the design is section 3.9 of grails-forge/FORGE-CLI-DESIGN.md (revision 150).
  • The upgrade skill: grails-skills/upgrade/skills/grails-upgrade/SKILL.md.
  • The threat model (THREAT_MODEL.md, threat-model.yaml): the entries for feature packs, the plugin index, and the project directory and its Gradle wrapper (a project above the current directory is used only when the user owns it, GRAILS_SAFE_DIRECTORY; Gradle is given an init script that runs the tasks of a project only in the directory its path names).

How the command line changes from Grails 9

Examples of each are in the next section; the complete mapping is upgrade note 27.

  • The wrapper updates itself: once gradle.properties names Grails 10, ./grailsw update-wrapper replaces grailsw, grailsw.bat and grails-wrapper.jar with those of Grails 10, to be committed. A tool that started the command line starts the Main-Class of the grails-cli jar; a program that calls GrailsCli.execute compiles against org.apache.grails.forge:grails-forge-cli.
  • No --profile, create-profile or other profile commands; a profile dependency fails the build; grails.profile is not read.
  • --features adds to the defaults and refuses unknown names; --exclude-features drops a default; a profile of one's own becomes a preset. grails create-app --inplace without a name names the application after the current directory.
  • An environment in front of the command (grails prod war, grails test run-app) is refused: write -Dgrails.env= after the command. A tool of a plugin typed by its name runs for development; name another environment with run-tool.
  • test is no longer another name of test-app; run and stop still are other names of run-app and stop-app; exit and quit both end the console; open is removed (!open FILE does it).
  • Short forms work as in Grails 9 and also in lower case; a short form that fits two commands is refused instead of running the first.
  • Exit codes: 2 for a mistake in the command line (nothing runs), 1 for any other failure.
  • stop-app stops only what grails run-app started.
  • create-* commands fail when a file exists, unless --force; project templates are text and are not executed. create-controller in a REST API project writes a controller with static responseFormats = ['json'], as the profile did.
  • generate-all, generate-controller and generate-views in a REST API application are the scaffolding plugin's commands and need the scaffolding feature (create-restapi --features scaffolding, or feature add scaffolding); generate-all writes no functional spec, and generate-unit-test, generate-functional-test and generate-resource-controller are removed.
  • New commands: feature add|list|find|show|diff, plugin list|find|show, project show|regenerate|migrate|health, and create-<name> for each command a feature of the project declares. One letter is short for each command of the two groups (grails f s postgres, grails pl f security).
  • New options of the create commands: --feature-option FEATURE.NAME=VALUE, beside --preset, --feature-pack-dir, --feature-pack-repository, --feature-pack-sha256, --feature-catalog, --refresh and --offline; feature add takes the same pack options.
  • create-script and create-command are removed: a new tool is a class made with create-tool, in src/cli, or with --standalone in src/standalone; existing scripts and the classes of grails-app/commands still run, deprecated. In a plugin, create-tool puts a tool without a package into <package>.cli (<package>.cli.standalone for a standalone one), so no package of a plugin is in two of its jars.
  • The tools of the application and its plugins are run by their names; in a checkout that was never built, the first one typed has the build list them (GRAILS_LIST_TOOLS=false turns that off; GRAILS_LIST_COMMANDS is no longer read). run-tool NAME is for an environment, a name a built-in command has, and automation; run-command still works, with a warning.
  • Code of the application that used a library declared only in grailsCli declares it with implementation: grailsCli is on the class paths of the tools and the tests, not on the compile class path of the application. A source that imports grails.dev.commands.* imports org.apache.grails.core.cli instead (project health: tools.grails7-imports).
  • ~/.grails/settings.groovy is not read; proxies go to GRAILS_OPTS.
  • The REST API plugin type is created as the profile created it: an empty UrlMappings, no controller, no views.
  • An application with GORM for Neo4j uses grails-neo4j-bom in place of grails-bom.

Before and after: Grails 9 and Grails 10 command lines

What you typed with Grails 9 on the left, what you type with Grails 10 on the right. shop, Book and com.example stand for your own names.

Unchanged

Grails 9 Grails 10
grails create-app shop
grails run-app
grails compile
grails clean
grails war
grails create-domain-class Book
grails add-property Book title:String
grails create-service Inventory
grails cDC Author
grails stats
grails run, grails stop
The same command lines

Creating an application

Grails 9 Grails 10
grails create-app shop --profile rest-api grails create-restapi shop one create- command per application type
grails create-plugin audit --profile rest-api-plugin grails create-rest-api-plugin audit
grails create-app shop --features mongodb grails create-app shop --data mongodb --features no longer replaces the default features
— grails create-app shop --features postgres,grails-quartz added to the default features; an unknown name: exit code 2
— grails create-app shop --exclude-features mockito leaves a default feature out
grails-forge-cli create-app shop
grails -t forge create-app shop
grails create-app shop one command line; -t and --type: exit code 2
GRAILS_PREFERRED_SHELL=forge grails create-app shop grails create-app shop the variable is not read
cd my-shop && grails create-app --inplace cd my-shop && grails create-app --inplace named after the directory (my-shop, package my.shop); the Forge CLI of Grails 9 refused it
cd com.example.store && grails create-app --inplace cd com.example.store && grails create-app --inplace com.example.store a directory name with a dot: exit code 2, give the name
grails create-app shop --profile com.acme:acme-profile:1.0.0 grails create-restapi shop --preset com.acme:acme-preset:1.0.0 your profile, converted to a preset

Running, building and testing

Grails 9 Grails 10
grails test run-app grails run-app -Dgrails.env=test the environment follows the command; test, prod, dev in front: exit code 2
grails prod war grails war -Dgrails.env=production
grails -Dgrails.env=staging war grails war -Dgrails.env=staging a -D in front of the command: exit code 2
grails run-app, then grails stop-app in another terminal grails run-app --detach
grails stop-app
returns once the application answers: one terminal, or a CI job
grails --offline run-app grails run-app -- --offline Gradle options follow --
grails test-app grails test-app runs every test phase, functionalTest included
grails test-app grails test-app --unit --integration only the two phases Grails 9 ran
grails test-app -unit grails test-app --unit -unit still works
— grails test-app --functional one phase the build adds
— grails test-app -- -x functionalTest every phase but one
grails test-app BookSpec grails test-app BookSpec runs the test in whichever phase has it
grails test-app -stacktrace grails test-app --stacktrace two dashes; an option the command does not have: exit code 2
grails shell grails shell the Groovy shell of the application; Grails 9 only said to run gradle shell -q
grails rA grails rA
grails ra
short forms also in lower case: ra, sa, cdc; grails help ra ends with the short form
grails cS Inventory grails cS Inventory
grails cs Inventory
create-service: create-script, which cS also fitted, is removed
grails crete-app shop ends with exit code 1 grails crete-app shop ends with exit code 2 2: a mistake in the command line, nothing ran; 1: any other failure

Creating classes

Grails 9 Grails 10
grails create-controller Book a second time: file kept, exit code 0 grails create-controller Book --force without --force an existing file fails the command (exit code 1)
grails create-unit-test BookSpec writes BookSpecSpec.groovy grails create-unit-test BookSpec writes BookSpec.groovy
grails create-controller Book grails project migrate
grails create-controller Book
in an application the Grails shell created: project migrate writes its record, .grails, once
grails generate-all com.example.Publisher grails generate-all com.example.Publisher the scaffolding plugin's command, GSP views
grails generate-all Book in a REST API application grails feature add scaffolding
grails generate-all Book
the REST controller, its service, their specs and JSON views; no functional spec. --views=json where the application also has GSP views
— grails create-audit-listener Order a command a feature gives (artefacts of its pack), from the template under src/main/templates/features/<feature>/
grails install-templates grails run-tool install-templates the scaffolding templates; grails install-templates now copies those of the create-* commands
grails create-script data-import
grails create-command data-import
grails create-tool data-import
grails create-tool --standalone data-import
create-script and create-command are refused (exit code 2, with a line that names create-tool); scripts and grails-app/commands are deprecated and still run
grails create-job Nightly grails create-job Nightly needs the grails-quartz feature

Commands of plugins and of the application

Grails 9 Grails 10
grails dbm-update
grails s2-quickstart com.example User Role
grails url-mappings-report
grails data-import orders.csv
The same command lines tools of plugins and of the application, run as their folder says (by the build, or as a process of their own); in a checkout that was never built, the first one typed has the build list them first
grails prod dbm-update grails run-tool -Dgrails.env=production dbm-update grails dbm-update -Dgrails.env=production runs in development, with a warning; run-command still works, with a warning
grails hello (a script in src/main/scripts) grails hello still runs, with a warning that scripts are deprecated; rewrite it as a tool (grails create-tool hello)
grails acme-sync orders grails gradle runScriptCommand --arg=acme-sync --arg=orders a deprecated script of a third-party plugin (META-INF/commands/acme-sync.groovy), until the plugin ships it as a command

Features and the record of a project

Grails 9 Grails 10
— grails feature add database-migration adds a feature to an existing application
— grails feature add postgres replaces the default h2
— grails feature add mysql --replace replaces postgres, which was asked for by name
— grails feature add cache --dry-run shows what would change, changes nothing
— grails feature list the features the application has, and those it can get
— grails feature find database the features with a text in their name, title, description or category
— grails feature show postgres
grails feature info postgres
what a feature is and what it contributes; --type rest-api for a new application of that type
— grails feature diff grails-quartz the unified diff feature add would apply, on the standard output; exit code 0 when it can be added
— grails feature add com.acme:acme-audit-grails:2.3.0 the feature of a plugin's pack, by the coordinates of the plugin
— grails feature add com.acme:acme-audit-grails:2.3.0 --feature-option acme-audit.table=audit_log an option the pack declares as a parameter
cat grails-forge-cli.yml grails project show how the application was generated, and the create- command that makes it again
— grails project regenerate --diff the files that differ from what was generated; exit code 1 when it lists one
— grails project migrate
grails feature add grails-quartz --dry-run
an application of Grails 7, 8 or 9 gets the record .grails with a baseline, and feature add works in it
— ./grailsw update-wrapper
./grailsw project migrate
after changing grailsVersion to a later 9.x: moves the record to it
— grails project health --strict what is left to upgrade, each with its fix; exit code 1 while an error or a warning is left

The Grails wrapper and the version

Grails 9 Grails 10
./grailsw update-wrapper ./grailsw update-wrapper once grailsVersion names Grails 10: replaces grailsw, grailsw.bat and grails-wrapper.jar; commit them
./grailsw update-wrapper run-app ./grailsw update-wrapper
./grailsw run-app
update-wrapper takes no arguments: exit code 2
grails -v grails --version -v is --verbose
grails -version grails -V

Plugins

Grails 9 Grails 10
grails list-plugins grails list-plugins security also outside a project; lists by a text
grails plugin-info spring-security-core grails plugin-info spring-security the name in the Grails plugin index, or org.apache.grails:grails-spring-security
— grails plugin list
grails plugin find security
grails plugin show spring-security
the same two commands in a plugin group; plugin find requires the text, plugin info is plugin show

Interactive mode

Grails 9 Grails 10
grails grails interactive mode in a project; the help elsewhere
grails> quit grails> quit
grails> exit
both end the console
grails> !ls grails> !ls the rest of the line runs in the user's shell, as in Grails 9

Removed commands

Grails 9 Grails 10
grails test grails test-app
grails install grails gradle publishToMavenLocal the build of the plugin has to apply a publishing plugin: the grails-publish feature of the plugin types does (create-plugin --features grails-publish)
grails open build/reports/tests/test/index.html open build/reports/tests/test/index.html
grails> !open build/reports/tests/test/index.html
the command of the system (xdg-open, start), also with ! in interactive mode
grails list-profiles grails help lists the create- commands
grails profile-info rest-api grails create-restapi --list-features
grails create-profile acme — write a preset instead, and create with --preset
grails run app.groovy grails run-script app.groovy in an application; grails run app.groovy is refused with exit code 2 and says so

Speed

Measured on one machine (macOS, JDK 21, the installed distribution, a cold JVM). The logic of a command is 15–35 ms; the rest is the start of the JVM, Groovy and about 2,000 classes, which the start scripts shorten (-XX:TieredStopAtLevel=1 for a single command, not for the console), the classes a command uses are loaded ahead on a second thread, and the templates of the bundled packs are compiled when Forge is built.

Before After
grails --version 523 ms 365 ms
grails create-controller Foo 675 ms 476 ms
grails create-app 1,961 ms (9.0 s CPU) 1,361 ms (2.7 s CPU)
grailsw --version 489 ms 320 ms
feature add --dry-run, project regenerate --diff 1,141 ms 1,002 ms
publish to the test repository, clean tree 7 min 15 s 2 min 55 s
Forge specs on Windows in CI 70–85 min 41 min

How it is tested

Specifications drive the command line as a user does (one-shot and the console, both ways of running Gradle) and the Gradle plugin through TestKit; every bundled pack is compiled in a generated application and its runtime class path resolved; the generator's output is compared with golden files; a Windows job runs the Forge core and command-line specifications. The guide's examples of the tour were run by hand, and four upgrade journeys (an application of Grails 9 upgraded and migrated, a new application through to run-app and stop-app, external packs, a staged distribution) are reported in a comment. The specifications that start processes wait for what happens and not for a time: a stub of the Gradle wrapper and the specification talk through a handshake (Handshake, SpecWaits in the test fixtures of grails-forge-cli), every wait has one bound that only ends a run that is stuck (5 minutes, times GRAILS_SPEC_WAIT_FACTOR), and the waits of the product that a specification would wait out can be set by it.

What differs from Grails 9 for users of tools

  • A tool that declares its options or parameters refuses what it does not take (upgrade notes 40 and 42), and the tools of Grails declare theirs: an unknown option, a value given to a switch, a missing required value, a value that is not a whole number or not one of the choices, and a surplus argument end a tool with exit code 2 and | Error NAME: <what>. grails help NAME shows its options, before Gradle or the application starts. In Grails 9 such arguments were ignored, or the tool failed later with exit code 1. A switch does not take the word after it: --force FILE is the switch and the file. An option is written with two hyphens. dbm-status --verbose takes true or false.
  • A tool that declares readsInput is refused under --non-interactive and is given the terminal otherwise (note 41).
  • The Grails wrapper writes its own messages to the standard error (note 39), so that the standard output of ./grailsw mcp is the protocol from the first run, the one that downloads the command line.
  • help --json has the type of every option and parameter, and for a tool its options, parameters, hints, readsInput and incomplete, each only where it says something (note 23).
  • grails-forge-cli depends on the MCP Java SDK, and through it on Reactor and Jackson 3, at the versions the Grails BOM manages. A program that embeds the command line and never runs mcp can exclude them. The CLI jar carries their licenses and notices (MIT for the SDK, MIT-0 for reactive-streams).
  • The dbm-* tools (note 42). dbm-generate-changelog and dbm-generate-gorm-changelog honour excludeObjects and includeObjects, as dbm-diff and dbm-gorm-diff do. A change log name without an extension is NAME.groovy for the default data source (Grails 9: NAME-dataSource.groovy) and NAME-DATASOURCE.groovy for another, and dbm-create-changelog takes such a name. The tools that write their output to a file (the ten -sql tools, dbm-status, dbm-list-locks) write only a new file inside the project: a file outside it, or one that is there already, is refused before the database is opened, where Grails 9 took any path and replaced the file. dbm-mark-next-changeset-ran takes no file name.
  • A plugin whose classes an application uses is declared by the application (note 34). In Grails 9 the -cli companion of every plugin on the runtime class path was on the compile class path and depends on its plugin, so the classes of a plugin behind another plugin compiled without a dependency. An application with grails-spring-security-rest-gorm or -grailscache that uses @Secured or SpringSecurityService declares implementation "org.apache.grails:grails-spring-security".
  • Scripts of plugins are found by the entries of each jar on the class path, also of a jar that has no entry for META-INF/commands, whatever the capitals of the file name (Create-Thing.groovy is create-thing). No script is taken from a jar without a manifest; such a jar that has scripts is named on the standard error.
  • Processes the command line starts. Gradle and a standalone tool are stopped when grails is ended, from the moment they are started. Every JVM that runs a tool has native access from Java 22 (the command line for a standalone tool, the Gradle plugin for runTool and its kin), so no warning of the JDK is in the output of a tool. The history file of the console, ~/.grails_history, is created readable by its owner only.
  • Reference pages. The Database Migration pages of both Hibernate lines are written from the declarations of the tools, one page a tool. The page of schema-export says what the tool does: both of its actions write the DDL script, and neither runs it against the database.

Known limitations

  • The features of plugins can be selected by name only once Record the Forge feature pack of a plugin version in the plugin index grails-plugins-metadata#326 is merged and the index is written again (see above).
  • IntelliJ IDEA needs Support the Grails 10 command line for projects of Grails 10 and later grails-intellij-plugin#477 for a Grails 10 project.
  • feature add in an upgraded application still conflicts where a change has to be in one place that the application lays out otherwise: an entry added to a list of the build file, a configuration value changed in an application.yml of another layout, lines added to a class. The conflict names the lines and writes nothing; feature add --diff shows the change to make by hand.
  • A REST API application that selects the scaffolding feature has the standalone tools of the plugin and not the plugin (grailsCliStandalone "org.apache.grails:grails-scaffolding-cli-standalone"): nothing of scaffolding, GSP or the fields plugin is on any of its class paths, its tests' and its tools' included. create-scaffold-controller, create-scaffold-service and generate-scaffold-all are listed although the classes they write need the plugin.
  • run-app --query-tail is an option the command line artifact of Grails Data declares, so run-app has it once the project has been built; before that, grails run-app -Pgrails.gorm.queryTail.enabled does the same.
  • A standalone tool whose class path has a file outside the build, the Gradle user home and the local Maven repository is not started until that directory is named in GRAILS_SAFE_DIRECTORY; run-tool NAME runs it with Gradle. Standalone tools were not run on Windows.
  • An application whose record has a --feature-option or a feature with commands is not read by a grails of an earlier build of this branch.
  • GORM for Neo4j cannot be combined with Hibernate 7 or Micronaut: no Grails BOM covers both.
  • grails mcp speaks MCP 2026-07-28 only. A client that starts with the older initialize handshake is answered with error -32022, which names the supported revision; the guide says which clients and settings speak it.
  • grails mcp was not driven by hand from Claude Code or Cursor: the specifications drive it with the MCP Java SDK's own client, in process and as a real process in a generated application with a real Gradle. None of its specifications runs on Windows.
  • Over MCP the choices of an option are written exactly as declared (json, not JSON), also for the tools that take any case at the terminal: the input schema has them as an enum.
  • Limits of the declarations: no option takes an optional value; declarations on the class are read from the tool class itself, not from a trait, so a shared set is an @AnnotationCollector on each tool; a tool that takes no arguments cannot say so, and stays free-form over MCP; the compiler's check that a tool reads its arguments sees only the tool class's own code; the compiler prints its warnings only when it really compiles, not when the classes come from the build cache (help NAME and project health still say what a tool lacks).
  • The dbm-* tools that write change logs (dbm-generate-changelog, dbm-diff, dbm-create-changelog and the like) and dbm-db-doc can write outside the project; only the tools that write SQL, status and lock output are confined to it.
  • Not verified against a release staged in the ASF repository; a distribution staged in a local repository was bootstrapped by hand.

What the original plan promised and this PR leaves out

Each of these is left out on purpose.

  • Repository credentials, settings.xml and ~/.grails/forge.yml. The command line fetches the jar of a pack from GRAILS_REPO_URL, Maven Central or --feature-pack-repository, without credentials. Reading credentials means deciding where they come from and making sure they are never recorded or printed, which is a design of its own; a private repository is reached today as a directory (file:) or through a mirror that needs no login.
  • A separate, reviewed project init. The plan had a command that shows the whole difference between an application and what Grails 10 generates and lets the user review it before a baseline is written. project migrate adopts instead: it writes the baseline in one step from the evidence it prints, and --force corrects it. One command and no interactive step serve an upgrade in a script as well as at a terminal.
  • project migrate does not edit build files. It writes .grails and nothing else, so it can run before the project builds and never touches a file the user owns. The profile dependency is removed by hand: the build of Grails 10 refuses that line and says to remove it.
  • The three test commands of the rest-api profile and the functional spec of generate-all. generate-unit-test, generate-functional-test and generate-resource-controller are not carried over, and generate-all writes no <Name>FunctionalSpec, which used the Micronaut HTTP client. create-unit-test and create-functional-test write tests, the latter against the running application with the HTTP client of the JDK.
  • The hosted Forge takes no external packs. A pack is code of somebody else, and start.grails.org runs none: it generates with the features of Grails only, and does not show instructions.
  • Fingerprints of overridden templates. The command line does not record which templates under src/main/templates a project changed, so it cannot say when a built-in template moved on; the templates are the project's files, under version control like the rest.
  • open. The console command that opened a file is removed; !open FILE runs the command of the operating system from the console.
  • Tools of a plugin that run inside the command line itself, with console services injected. The command line runs no code of a project or of a plugin in its own JVM. What the plan wanted from such a tool, a start without Gradle, is the standalone tool: a process of its own.
  • Running tools from a packaged application. A tool is run in the project, by the build or as a process of its own; nothing of a tool is in the application's archive.

  • Feature packs for less-asset-pipeline and for the security feature of the rest-api profile. Both are retired; the upgrade notes name the dependency to declare for each. maven-publish of the plugin profile is the optional grails-publish feature of the plugin types.
  • grails-publish is not a default of the plugin types. A generated plugin has the version 0.1, which the publish plugin takes for a release to sign; a plugin author selects the feature.

Related

@jdaugherty
jdaugherty requested review from matrei and removed request for matrei November 21, 2026 23:10
@jdaugherty jdaugherty added this to the grails:9.0.0-M1 milestone Nov 21, 2026
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.19005% with 582 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.5154%. Comparing base (b209be8) to head (00c2ef8).

Files with missing lines Patch % Lines
...grails/core/cli/compiler/ConstructionReader.groovy 60.7034% 129 Missing and 128 partials ⚠️
...vy/org/apache/grails/core/cli/ToolArguments.groovy 57.8595% 53 Missing and 73 partials ⚠️
...ils/core/cli/compiler/ToolDeclarationReader.groovy 80.9859% 15 Missing and 39 partials ⚠️
...org/apache/grails/core/cli/ConfigReportTool.groovy 80.6931% 11 Missing and 28 partials ⚠️
...apache/grails/core/cli/StandaloneToolRunner.groovy 35.5932% 26 Missing and 12 partials ⚠️
...vy/grails/codegen/model/DomainFieldModifier.groovy 85.8696% 0 Missing and 26 partials ⚠️
.../core/cli/ApplicationContextCommandRegistry.groovy 76.3889% 6 Missing and 11 partials ⚠️
...che/grails/core/cli/compiler/ToolCodeReader.groovy 82.1429% 2 Missing and 8 partials ⚠️
...ails/core/cli/ApplicationCommandDiagnostics.groovy 70.5882% 1 Missing and 4 partials ⚠️
...oovy/org/apache/grails/core/cli/ToolResults.groovy 58.3333% 4 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##             10.0.x     #17114         +/-   ##
=================================================
+ Coverage          0   71.5154%   +71.5154%     
- Complexity        0      44613      +44613     
=================================================
  Files             0       2746       +2746     
  Lines             0     146967     +146967     
  Branches          0      29571      +29571     
=================================================
+ Hits              0     105104     +105104     
- Misses            0      28292      +28292     
- Partials          0      13571      +13571     
Files with missing lines Coverage Δ
...ails/codegen/model/AbstractMemberDefinition.groovy 89.6552% <100.0000%> (ø)
...org/apache/grails/core/cli/ExecutionContext.groovy 100.0000% <100.0000%> (ø)
...oovy/org/apache/grails/core/cli/ProjectInfo.groovy 100.0000% <100.0000%> (ø)
...cli/compiler/CommandFactoriesTransformation.groovy 93.3333% <100.0000%> (ø)
...ails/core/cli/compiler/ToolDescriptorWriter.groovy 81.9444% <ø> (ø)
...g/apache/grails/core/cli/compiler/ToolRules.groovy 88.2353% <ø> (ø)
.../apache/grails/core/cli/compiler/ToolSource.groovy 64.2857% <ø> (ø)
...apache/grails/core/cli/script/ScriptCommand.groovy 86.7924% <ø> (ø)
...ails/core/cli/script/ScriptCommandException.groovy 100.0000% <ø> (ø)
...apache/grails/core/cli/script/ScriptConsole.groovy 92.1569% <ø> (ø)
... and 50 more

... and 2686 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jdaugherty

Copy link
Copy Markdown
Contributor Author

I've made some changes to significantly speed up the forge build & associated tests. This should reduce the time from 1hr 20 min to significantly less.

@jdaugherty

Copy link
Copy Markdown
Contributor Author

End-to-end journeys, by hand, at d1c26f6 (findings fixed in 72c18eb)

The journeys the review of 2026-11-22 asked for, run once every review item was addressed. macOS, JDK 21.0.12. The command line is the distribution built from this head (apache-grails-9.0.0-SNAPSHOT-bin.zip, unzipped; nothing else on the PATH); the framework and the grails-cli jars are staged in a local repository and named with GRAILS_REPO_URL; every wrapper ran with a GRAILS_WRAPPER_HOME of its own, empty at the start. Since 9.0.0 is a snapshot, the build files of journey 1 name the staged repository: the one step a release would not need. For the wrapper of Grails 8.0.0 the command line was staged in the layout of a local Maven repository: that wrapper reads only maven-metadata-local.xml in a directory (the Grails 9 wrapper reads both layouts, note 50).

1. A real Grails 8 application, upgraded. Created by the released Grails 8.0.0 (grails create-app com.example.legacy, the shell and the web profile; 8.1 has no release), committed, compiled on 8.0.0. Then, as the upgrade notes say: grailsVersion=9.0.0-SNAPSHOT, the profile dependency removed (note 39), and ./grailsw update-wrapper with the wrapper of 8.0.0: it downloaded the 9 command line, started DelegatingShellApplication, and replaced grailsw, grailsw.bat and grails-wrapper.jar (now 41,216 bytes), exit 0. ./grailsw project migrate wrote the record (type from the profile, 14 features each with where it was found, nothing outside .grails); since 72c18eb it takes the servlet from the declared starter (tomcat (build.gradle declares org.springframework.boot:spring-boot-starter-tomcat)), where it said (assumed). With no change to the code of the application: compile passed, run-app --detach answered with the welcome page, stop-app stopped it, test-app passed, create-controller Book wrote the controller and its spec, and feature add cache was refused with the reason (a record project migrate wrote for an application of Grails 8).

2. A generated application, edited, given a feature, built and run. grails create-app com.example.shop, committed; a controller of my own and a key added under info in application.yml; feature add grails-spring-security --dry-run --json (outcome changes, the files to add and update), then feature add grails-spring-security: both edits kept. grails gradle grailsCommandCatalog listed the commands of the plugins; grails help s2-quickstart described one without running anything; grails s2-quickstart com.example.auth Person Authority ran without the application and generated PersonPasswordEncoderListener, registered in resources.groovy (since 72c18eb, in an application with the feature's settings it writes nothing and exits 1 unless given --force, see below). At run time (run-app --detach --port 18181): a Person saved in BootStrap with the password secret is stored as {bcrypt}$2a$10$…; a secured page redirects to the login page; logging in with secret succeeds and with a wrong password goes to login_error=1. stop-app stopped it; project regenerate --diff lists the ten files that are not as generated.

3. The catalog, test-app --functional, a failing test. A functionalTest phase added as the guide says (testPhases { functionalTest { } }); grails gradle grailsCommandCatalog then lists the phase, and grails help test-app offers --functional. A deliberately failing @Integration specification there (text == 'secret' against the stored {bcrypt}…): grails test-app --functional ran functionalTest alone, the application started, the specification failed, and the command ended with exit code 1. Corrected, the same command ended with 0.

4. A fresh wrapper from the staged distribution. In the application of journey 2, with only Java on the PATH and an empty wrapper home: ./grailsw --version downloaded grails-cli-9.0.0-SNAPSHOT-all.jar from the staged repository and printed Grails Version: 9.0.0-SNAPSHOT. The installed jar is the staged one byte for byte (SHA-1 3cdc016b…, which is the repository's .sha1; SHA-256 48e9c9b6…), and no file of the wrapper was changed. A copy of the repository with one byte of the jar changed: the download was refused (does not match the SHA-1 checksum of the repository); since 72c18eb the wrapper then ends with exit code 1 and installs nothing (at d1c26f6 it went on to repository.apache.org and installed another build, see below). With the verified jar, ./grailsw run-app --detach answered and ./grailsw stop-app stopped it.

5. Windows. Not run by hand. The Windows jobs of this pull request (the Forge specifications, the core build) passed at 7739cc5; the runs of the later heads are in CI.

6. The IDE. apache/grails-intellij-plugin#477 (draft) supports this command line in the IntelliJ plugin; it was not run in an IDE.

Found by the journeys, and fixed in 72c18eb

Each re-run by hand with the distribution of 72c18eb:

  • A download that fails its checksum fell through to another repository. With GRAILS_REPO_URL naming the staged repository with a changed jar, the wrapper refused it and then installed an older 9.0.0-SNAPSHOT from repository.apache.org, with exit code 0. Now the first repository that gives the jar decides: a download that is not whole ends the wrapper with exit code 1, installs nothing and asks no other repository (also for Maven Central and the ASF repository). A repository that does not have the jar is still passed over.
  • s2-quickstart replaced the settings of the grails-spring-security feature. Run after the feature, it appended a second block of settings, and the later block dropped the feature's /user/** -> ROLE_ADMIN rule without a word. Now it writes nothing and exits 1 when the configuration has a setting it would write, naming the file and the keys; --force writes as before.
  • run-app --detach with an application.yml that is not valid YAML listed the reader's limits instead of the error, and advised --port although it was given. Now: grails-app/conf/application.yml is not valid YAML at line 3, column 3. Nothing was started; give the address with --host, or stay with the application with --foreground (the address is still read from the file when --port is given).
  • project migrate assumed the servlet of a build that declares spring-boot-starter-tomcat. It takes it from the starter now.

Verification at 72c18eb, besides the runs above: grails-wrapper 182 tests, the Spring Security plugin 341 and its commands 63, grails-cli 117, grails-forge-cli 2,782 (on the branch of the fix), code style, the guide with no AsciiDoc warning.

@jdaugherty

Copy link
Copy Markdown
Contributor Author

A tour of this change, by common scenario

What this pull request changes for a user, scenario by scenario, with the class that implements each. Links are pinned to 546585e832b. The guide's own walkthrough is tour.adoc; the decisions are in FORGE-CLI-DESIGN.md §3.

The big picture

Grails 8 had two command lines (the Grails shell with profiles, and the Forge CLI). Grails 9 keeps Forge, calls it grails, and teaches it everything the shell did inside a project. Three ideas carry the rest:

  1. A project = an application type + features. Profiles are gone; most features are declarative feature packs (61 bundled).
  2. A generated project keeps a record of how it was generated, in .grails/, which is what lets you add a feature months later.
  3. Anything needing the application's classes runs in the project's own Gradle build. grails ships no Gradle of its own.
./grailsw ──► grails-wrapper.jar (downloads grails-cli-VERSION-all.jar into ~/.grails/wrapper)
grails    ──┐
            ▼
  org.apache.grails.cli.DelegatingShellApplication   (grails-cli: plain Java, only starts Main-Class)
            ▼
  org.apache.grails.forge.cli.GrailsCli              (grails-forge-cli: picocli root ForgeCommand)
            ├─► help / version / refusals          → nothing else starts
            ├─► create-* / feature add / regenerate → starts the Forge generator (always production env)
            └─► compile / test-app / run-app / app commands → the project's Gradle build
                    one-shot command : ./gradlew as a process (Gradle owns the terminal)
                    interactive mode : Gradle Tooling API, one kept connection (~50 ms/build vs ~350)

Code: DelegatingShellApplication, GrailsCli. How Gradle is run is decided in one place, GradleBuild.of (override with GRAILS_GRADLE_RUNNER=process|tooling-api|auto; GRAILS_CLI_DIAGNOSTICS=true says which path each command took and why).


Scenario 1: Create a new application

$ grails create-app com.example.shop --features grails-quartz --exclude-features mockito
$ grails create-restapi api                      # was: create-app --profile rest-api
$ grails create-rest-api-plugin audit            # new type; was --profile rest-api-plugin
$ grails create-app --list-features              # (+) marks defaults

What's different:

  • One create-* command per application type (create-app, create-restapi, create-plugin, create-web-plugin, create-rest-api-plugin); --profile is gone.
  • --features adds to the defaults (Grails 8's Forge CLI replaced them); an unknown name is exit code 2 before anything is written. --exclude-features drops a default.
  • --jdk, --servlet, --data, --reloading choose between alternatives. An option left out is a default that yields to a feature needing something else; an option given is a choice, and a contradicting feature is refused up front.
  • The BOM follows --data: grails-bom (Hibernate 5), grails-hibernate7-bom, or grails-neo4j-bom. Uncovered combinations (Neo4j + Hibernate 7 or Micronaut) are refused with the reason.
  • A profile of your own becomes a preset: grails create-restapi shop --preset com.acme:acme-preset:1.0.0 (a pack of kind: preset that picks the type, sets option defaults, and asks for features).
  • create-app --inplace without a name now names the app after the directory.

What a feature looks like now, e.g. grails-forge-bundled/grails-quartz/feature.yml:

kind: feature
name: grails-quartz
compatibility: { grails: '[9.0.0,10.0.0)', forge: '[9.0.0,10.0.0)' }
dependencies:
  - scope: implementation
    coordinates: org.apache.grails:grails-quartz
configuration:
  quartz.autoStartup: true

A pack can only add (dependencies, config, rendered files). It can't overwrite another feature's setting or a dependency version; conflicts fail with both sides named. build.gradle is generated from a model, not templated. 13 features stay classes because they are the engine (build file, config formats, BOM, wrapper, …).

Scenario 2: What's in the new project (.grails/)

File Holds
.grails/project.yml What was asked for: type, name, package, options, requested/excluded features
.grails/forge.lock.yml What that resolved to: Grails version, every applied feature in order, generator build digest
.grails/baseline/ A copy of every generated file, as generated

Commit it (the baseline is the merge ancestor for Scenario 6), don't edit it (the files carry each other's digests; a hand-edited record is refused), and the running app never reads it. Code: ProjectStateRecorder, ProjectState.

Scenario 3: Create classes

$ grails create-domain-class Book    # + BookSpec
$ grails cDC Author                  # short forms still work…
$ grails cdc Author                  # …now in lower case too
$ grails cC Book                     # refused (exit 2): fits create-controller and create-command
$ grails create-job Nightly          # exists only because the record has grails-quartz
  • The command list depends on the record: create-job needs grails-quartz; create-restful-controller only in REST types; create-functional-test writes Geb or HTTP tests by type.
  • An existing file fails without --force (Grails 8 silently kept it and exited 0).
  • An ambiguous short form runs neither and names the shortest form of each (Grails 8 ran the first match). Code: ShortForms.
  • create-unit-test BookSpec writes BookSpec.groovy, not BookSpecSpec.groovy.

Scenario 4: Build, test, run

grails Gradle
compile classes
test-app testApp, which runs every test phase
run-app bootRun
assemble / war / package assemble (production)
gradle ARGS… exactly those args
$ grails test-app                        # unit + integration + functionalTest + any other Test task
$ grails test-app --unit --integration   # what Grails 8's test-app ran
$ grails test-app BookSpec               # runs it in whichever phase has it
$ grails run-app -Dgrails.env=test       # was: grails test run-app (now exit 2)
$ grails run-app --detach && grails stop-app
$ grails compile -- --offline            # after -- goes to Gradle verbatim
  • test-app now includes functional tests, the most likely surprise. Code: TestAppTask.
  • The environment goes after the command; prod war or a leading -D is refused.
  • run-app --detach returns once the app answers on its port (read from application.yml); with the startup-progress page, a failed start is reported at once. stop-app only stops what run-app started (PID + start time + user + command line recorded in .grails/run).
  • A project above the current directory is used only if you own it (GRAILS_SAFE_DIRECTORY for exceptions; see the threat model).

Scenario 5: Commands of the application and its plugins

$ grails create-command data-import          # grails-app/commands/.../DataImportCommand.groovy
$ grails data-import orders.csv              # top-level, by name
$ grails s2-quickstart com.example User Role # plugin command, by name
$ grails help data-import                    # describes; runs nothing
$ grails run-command -Dgrails.env=production dbm-update

How it works: every build that compiles the project runs grailsCommandCatalog → .grails/cache/command-catalog.json, which grails reads without starting Gradle (so help stays instant). Typing a name not yet listed (fresh checkout, just after create-command) makes the build list once, then retry. The command runs in the build via the runCommand task with the application context over a mock servlet, or without the application if the class implements StandaloneCommand (query-tail is one). Code: GrailsCommandCatalogTask, ApplicationCommands.

The gotcha: everything after an app command's name is the command's own, so grails dbm-update -Dgrails.env=production runs in development (with a warning). Use run-command for the environment.

Scripts: deprecated. Existing src/main/scripts still run (via runScriptCommand, with a warning); create-script is removed in favour of create-command. The framework's own scripts became compiled commands (Spring Security s2-*, scaffolding, query-tail), and Quartz/Geb's scripts became create-job / create-functional-test. s2-quickstart now writes nothing if any environment already has a setting it would write, unless --force.

Plugin authors: commands go in src/cli/groovy with the grails-plugin-cli Gradle plugin, published in a companion artifact so they stay off the app's runtime classpath.

Scenario 6: Add a feature months later

$ grails feature list                 # has / can add / why it can't add the rest
$ grails feature add cache --dry-run  # or --diff for line-by-line
$ grails feature add postgres
| Adding the feature postgres, and with it testcontainers
    postgres replaces h2, the default of the group database-driver
    merge    build.gradle (your changes are kept)
    ...
$ grails feature add mysql --replace  # postgres was asked for by name, so --replace is required

How it works (FeatureAddition, ThreeWayMerge, ProjectTransaction):

  1. Replay. Generate the app twice in memory: from the record, which must reproduce .grails/baseline byte for byte, and with the new feature.
  2. Three-way merge per differing file, with baseline as ancestor, new generation as theirs, and your working copy as yours. An untouched file is updated, a file edited elsewhere is merged, and the same lines changed on both sides is a conflict. One conflict means nothing is written.
  3. All or none. Files are staged and renamed into place with a journal under ~/.grails/forge/transactions/…; an interrupted change is finished or undone file by file, never over a later edit.

Rules: a default the feature displaces is replaced (postgres → h2); a feature you asked for only with --replace; an option (--data, …) is never changed; nothing is removed on request; the Grails version never moves. It needs a tracked record (one Grails 9 generated). If the project used an external pack or preset, pass the same pack again so the replay matches.

Scenario 7: "What did we change?" and "is this project healthy?"

$ grails project show                 # every option (default or not) + the create-app line that rebuilds it
$ grails project regenerate --diff    # added/changed vs. generation; exit 1 if anything differs
$ grails project regenerate --output /tmp/pristine
$ grails project health --strict      # offline checks with stable ids; --json for CI

project health checks Grails/Gradle/Java versions, both wrappers and the Gradle checksum, removed or deprecated dependencies, the record, Git files, the command catalog, leftovers of earlier versions, and agent skills. Each finding has a level, the fix, and the upgrade note. Code: ProjectHealth.

Scenario 8: Upgrade a Grails 8 application

# 1. set grailsVersion=9.x in gradle.properties
$ ./grailsw update-wrapper            # old wrapper replaces itself; commit grailsw, grailsw.bat, grails-wrapper.jar
$ ./grailsw project migrate           # writes an *untracked* record from the project's files
$ ./grailsw project health --strict   # repeat until clean

Why the old wrapper works: every wrapper since Grails 7 starts DelegatingShellApplication. A Grails 9 wrapper sets grails.wrapper.version; an old one doesn't, so the class sets grails.cli.earlierWrapper=true and GrailsCli.mainOfEarlierWrapper runs update-wrapper first.

After migrating, an untracked record gives you the create-* class commands but not feature add or regenerate (no baseline to merge against; adoption via project init is not built). Until migrated, a pre-9 project refuses project commands (exit 1, one line), except project migrate and project health. Upgrade note 55 in upgrading90x.adoc maps every Grails 8 command line to Grails 9; grails-skills/upgrade/skills/grails-upgrade/SKILL.md walks the same steps.

Scenario 9: Interactive console

$ grails
grails> create-service Inventory
grails> run-app          # returns to the prompt once the app answers
grails> !git status      # ! runs a shell command, as in the old shell
grails> exit             # or quit

Builds go through the Tooling API on one kept connection; Ctrl-C cancels the build and returns to the prompt; TAB completes commands and, after feature add, the features the project lacks.

Scenario 10: Tools, CI and IDEs


What's gone

grails-shell-cli and the seven profile artifacts (a profile dependency fails the build); -t/--type; GRAILS_PREFERRED_SHELL; grails.profile; create-profile/list-profiles/profile-info; create-script; open (use !open); the test alias; install (use gradle publishToMavenLocal); grails run app.groovy (use run-script); ~/.grails/settings.groovy (proxies go in GRAILS_OPTS); REST scaffolding into JSON views. -v is now --verbose (the version is --version / -V).

External dependencies and limitations

Suggested reading order

tour.adoc, then upgrade note 55, then FORGE-CLI-DESIGN.md §3, then FeatureAddition.groovy and GradleBuild.groovy, where the hardest logic lives.

@jdaugherty

jdaugherty commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

How to test locally

These steps build this branch into a grails command line, publish the framework to ~/.m2 and copy what was published into a repository of its own. They then try the three things that changed:

  1. the command line in a new application
  2. the Grails wrapper of that application
  3. the wrapper of a Grails 8 application upgrading itself

You need JDK 21 and JAVA_HOME set.

1. Build and install

gh pr checkout 17114
./gradlew publishAllToMavenLocal                  # grails-gradle, the framework, and Forge with the grails-cli jar the wrapper downloads
(cd grails-forge && ./gradlew :grails-cli:installDist)

export PATH="$PWD/grails-forge/grails-cli/build/install/apache-grails-bin/bin:$PATH"
export GRAILS_REPO_URL="$(mktemp -d)"             # where generated builds and the wrapper find 9.0.0-SNAPSHOT
mkdir -p "$GRAILS_REPO_URL/org/apache" && cp -R "$HOME/.m2/repository/org/apache/grails" "$GRAILS_REPO_URL/org/apache/"
export GRAILS_WRAPPER_HOME="$(mktemp -d)"         # an empty wrapper cache, so the wrapper really downloads
export GRAILS_SAFE_DIRECTORY="$GRAILS_REPO_URL"   # a standalone tool is started only from a directory you trust; the staged repository is one
grails --version

publishAllToMavenLocal replaces any 9.0.0-SNAPSHOT already in ~/.m2.

GRAILS_REPO_URL is a copy of the published artifacts and not ~/.m2/repository itself: a local Maven repository often has the POM of a library without its jar, and Gradle then stops at that repository with Could not find …jar instead of going on to Maven Central. Copy again after publishing again.

Keep the four variables set in every terminal you test in. A generated application records GRAILS_REPO_URL in its build. feature add and project regenerate need the same value to generate the application again.

2. A new application, with the command line

cd "$(mktemp -d)"
grails create-app com.example.shop && cd shop
git init -q && git add -A && git commit -qm generated
cat .grails/project.yml                  # the record: type, options, features
grails create-domain-class Book
echo '// a change of my own' >> build.gradle
grails feature find cache                # the features with "cache" in their name or description
grails feature show cache                # what it is and what it would add here
grails feature diff cache                # the diff feature add would apply; writes nothing
grails feature add cache --dry-run       # "merge build.gradle (your changes are kept)"; writes nothing
grails feature add cache
git status --short
grails project regenerate --diff         # exit code 1: build.gradle changed, the Book files added
grails project show                      # ends with the create-app line that makes the same application
grails project health
grails create-tool report              # a tool in src/cli/groovy, run by the build
grails create-tool --standalone stamp   # a tool in src/standalone/groovy, run as a process of its own, without Gradle
grails report && grails stamp
grails help                              # the tools are listed in a section of their own
grails test-app
grails run-app --detach                  # returns once http://localhost:8080 answers
grails stop-app
grails                                   # the console: try  run-app,  !git status,  exit

A few of the refusals, with their exit codes, run in the same directory:

grails prod war; echo $?                 # 2: the environment goes after the command (war -Dgrails.env=production)
grails -t forge create-app x; echo $?    # 2: there is one command line
grails cC Book; echo $?                  # 2: cC fits create-controller and create-command
grails help --json | head -c 400

3. The Grails wrapper of that application

env PATH="/usr/bin:/bin" ./grailsw --version   # only Java (from JAVA_HOME): downloads grails-cli-9.0.0-SNAPSHOT-all.jar
ls "$GRAILS_WRAPPER_HOME"
./grailsw help
./grailsw run-app --detach && ./grailsw stop-app

4. A Grails 8 application, upgraded by its own wrapper

Start from a Grails 8.0.0 application that has grailsw, compiled once on 8.0.0 and committed. It can be one of your own or a new one from https://start.grails.org.

cd legacy
# in gradle.properties: grailsVersion=9.0.0-SNAPSHOT
# in build.gradle: delete the  profile "org.apache.grails.profiles:..."  line, if there is one (upgrade note 39)
# in build.gradle and settings.gradle: add  maven { url = uri(System.getenv('GRAILS_REPO_URL')) }  first in every repositories block (only a snapshot needs this)
./grailsw update-wrapper           # the 8.0.0 wrapper downloads the Grails 9 command line, which replaces the wrapper
git status --short                 # grailsw, grailsw.bat and grails-wrapper.jar (now about 41 KB) changed
./grailsw --version                # Grails Version: 9.0.0-SNAPSHOT, through the new wrapper
./grailsw project migrate          # writes .grails: the record and a baseline of what Grails 9 generates for what it found; changes no other file
./grailsw project show             # state: adopted
./grailsw project health
./grailsw compile
./grailsw create-controller Book
./grailsw feature add cache        # added: build.gradle and application.yml merged, your own lines kept
./grailsw feature add openapi --dry-run   # a conflict that names the lines, and writes nothing: one of the changes that still need a hand
./grailsw compile

Cleaning up

rm -rf "$GRAILS_WRAPPER_HOME"

The 9.0.0-SNAPSHOT artifacts stay in ~/.m2 until they are published again or deleted.

Not covered by these steps:

@jdaugherty
jdaugherty marked this pull request as ready for review November 24, 2026 10:33
@jdaugherty
jdaugherty force-pushed the feat/16348-one-generator branch from 4100b57 to cddda1a Compare November 24, 2026 11:15

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. A script whose file name is the command with a capital letter in the middle is not found in a jar.

@codeconsole codeconsole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work overall — the architecture, documentation, test coverage, and security hardening across grails-forge, grails-wrapper, grails-gradle, and the migrated plugin commands are remarkably thorough.

I'm requesting changes for a handful of concrete bugs found during review (detailed in the inline comments):

  • Console / CLI: JLine Terminal leak in InteractiveShell.start(), uncaught InterruptedException in ConsoleProgram.run() when interrupted in non-inherited mode, and ForgeCli.refusedIn() bypassing Grails 7/8 refusal when -V/--version appears after a command.
  • ReDoS in project health / project regenerate: consecutive * / ** wildcards in .gitignore and .gitattributes are not collapsed before regex compilation.
  • Parallel build race: TestRepositoryMarkerPlugin.InvalidateMarker has a TOCTOU race on marker.exists() && !marker.delete() across parallel publish tasks.
  • Additional minor bugs: StartClass.load leaking URLClassLoader on error paths and misreporting IOException as a missing start class, RunAppCommand non-volatile shutdown-hook fields, JCacheGrailsCacheManager masking non-race CacheException as IllegalArgumentException, S2QuickstartCommand multi-line doWithSpring() / duplicate insertion handling, S2uiOverrideCommand error message when passing a package to layout/auth, unremoved shutdown hook in QueryTailCommand, unclosed HttpClient in PackArtifacts, Windows stderr.encoding / UNC URI / missing task input issues, and minor actions/* tag version drift in workflows.

Also note that Coverage - grails-forge (ubuntu-24.04) failed on ToolingApiRunAppSpec (likely timing under JaCoCo instrumentation, as the non-coverage Forge jobs passed).

Comment thread .github/workflows/gradle.yml Resolved

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesfredley @codeconsole: every finding of reviews 6042723725 and 6044167874 is fixed at f4b4068. Each thread has the commit and the spec that covers it.

Two fixes go further than the suggestion:

  • The .gitignore/.gitattributes patterns are matched without a regular expression. Collapsing * alone still leaves *a*a…*b slow.
  • A script of a plugin is found in a jar without directory entries by listing the jar, not by another name guess. The order no longer follows the class path: Grails' jars first, then the rest by jar name and file name.

Coverage - grails-forge: ToolingApiRunAppSpec waited the full 300 s although run-app had already ended (its record .grails/run/app.json was gone, and run-app deletes it when the build ends), so it was not slowness under JaCoCo. The spec now stops waiting as soon as run-app ends and prints its exit code and output (aabb5c4). freePort() also requires that the port can be bound on the loopback address without SO_REUSEADDR, since another process can hold a port there that looks free on the wildcard address. It passed locally, so if it fails again the output will say why.

Comment thread .github/workflows/gradle.yml Resolved

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. A subclass that sets its own command name is recorded under the name it inherited.

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesfredley: the finding of review 6045650689 is fixed at 17ef512 (52a4314). The thread has the commit and the specs that cover it.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. A subclass that sets its command name in a helper is still recorded under the inherited name.

A base command sets its name to old-name, and the constructor of a
command that extends it calls a helper that sets the name to
import-data. The descriptor, and so the catalog, said old-name, while
the registry of commands, where runCommand looks the name up, knows the
command as import-data: the writer looked for statements that set the
property in the constructors and initializer blocks only, and code they
call was not seen. Any other way of setting it there was not seen
either: a method of a class the command extends, an overridden method
the constructor of the base class calls, a field initializer that calls
a method, a trait that gives its fields values, a method of the runtime,
reflection.

The writer now follows what runs when the command is made, in the order
it runs, from the class at the root down to the command: of each class
its field initializers, its initializer blocks and each constructor, and
the methods that code calls on the command, or the static methods of its
classes it gives the command to, when they are compiled with it. A
method is found as Groovy finds it: a private method of the class that
calls it, of methods with the same parameters the one nearest to the
command, every method the call can mean otherwise; at most 16 calls deep
and 256 calls for a property. The last statement that sets the property
to a string constant on every way the code can go decides, so name =
'a'; name = 'b' is now b where it gave no descriptor.

Anything that can set the property and is not read makes it unknown,
and the command gets no descriptor: a condition, a value given to the
method that sets it, recursion, a loop or try, this(...), a closure or
with, a method of another class or of a class compiled elsewhere, one of
the runtime (setProperty, a subscript, the meta class), reflection, a
trait other than those of the command contract that gives its fields
values, a class that overrides getProperty, setProperty, invokeMethod,
methodMissing or propertyMissing. Code that is not read and is not
given the command, such as new JsonSlurper(), cannot reach it and leaves
the property as it is, until the command has been handed to code that
is not read (a closure holds it; a class compiled elsewhere that it
extends may have handed it out); from then on any code that is not read
makes the property unknown. Changes to the meta class, methods of
extension modules and other threads are not seen.

A command without a descriptor is listed by the name its class name
gives, which need not be the name it has: runCommand did not find it by
the name it was listed by. findCommand of the registry now finds a
command by that name when no command has it as its own name; of two
classes that give the name, the one without a descriptor, which is the
one the catalog lists by it. A command of a Grails 7 plugin, listed the
same way, is found by the class of the command its adapter adapts.

CommandDescriptorWriterSpec compares, for each way of setting the name
(helpers private, final, overridable and static, helpers calling
helpers, a helper of the class extended, an override the base calls, a
field initializer, a conditional helper, closures, with, another class,
the runtime, a subscript, the meta class, reflection, a trait, code the
command was handed to), the descriptor or its absence with the name the
command has when it is made, and lists a command without a descriptor
and finds it by that name. ApplicationCommandProviderSpec and
LegacyCommandRegistryLoadingSpec find commands by the names their
classes give. GeneratedApplicationCommandSpec runs, in a generated
application, the command of the review and one whose name is worked
out, by the names the build lists them by. The guide says what the
descriptor reads and that a command listed by its class name runs by it.

Part of apache#16348
Upgrade note 32, the upgrade skill and revision 107 of the design say
which settings of a command's name the descriptor reads, and that a command
listed by the name its class name gives also runs by it.

Part of apache#16348

@codeconsole codeconsole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge after the fixes. Published Grails 9 command jars can break, feature addition can undo a permission change, and verification can fail spuriously or reuse a stale result. Keep forgePackTest simpler by letting the nested Gradle builds own up-to-date checks once fixture generation and execution can run separately. This was a source review. The PR materials included directions to build the branch and invoke TestLens. I left them unexecuted.

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeconsole, review 6177815872 (at cef9323) is answered at a7da44a, each finding in its thread:

  • Commands compiled with Grails 8 or 9 did not load. The two deprecated traits have their members again, and a spec runs commands compiled against the Grails 9 traits through the real runner.
  • A mode changed between staging and write ends the change and is kept.
  • forgePackTest runs each time it is asked for. @jamesfredley, this is also the answer to your thread on the same line.
  • The duration comparison of McpModernEraSpec is removed.
  • A malformed --feature-option with --json ends with 2, with the reason feature-option.
  • The stand-in rows of ConsoleCommandsSpec are unchanged: the behaviour of the build is tested in TestAppFunctionalSpec.

Run locally: :grails-core:testCli, :grails-console:test, ProjectTransactionFailuresSpec, FeatureAdditionSpec, FeatureAddJsonSpec, McpModernEraSpec, the ForgePackTest specs of the Gradle plugins, and codeStyle of the touched modules. The six commits are unsigned.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. A customized artifact name is not the name the metadata asks for, and a command class loses the name callers already use.

@codeconsole codeconsole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing command names can disappear or run a different command. Feature addition can override a migrated application's environment settings, and published CLI companions can have an unresolvable dependency. The supplied CI report also leaves the linked-wrapper startup failure unexplained.

This was a source review. The PR materials asked readers to check out and build the branch and to invoke TestLens. I used the supplied files and CI report.

Merge after the fixes and a passing linked-wrapper check.


where:
project | directories | build
'an integrationTest task that takes its sources from src/it/groovy' | ['src/it/groovy'] | "\ntasks.named('integrationTest') { inputs.dir('src/it/groovy') }\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two rows can be one forwarding test. inputs.dir does not configure test sources, and the stand-in testApp echoes the phase in both rows. Put the custom-source case in TestAppFunctionalSpec with a real test under src/it/groovy and assert that it ran.

In an application that project migrate adopted, feature add puts the
settings a feature adds to a YAML file under grails-app/conf into a
document of their own at the end of the file when the line merge finds no
place for them, and only when no document of the file sets one of those
keys, or a key above or below one. That check compared the keys as they
are written, so a key under environments.<name> was taken for another
setting. Grails reads each document of application.yml with the settings
under environments.<name> of the environment it runs in put in the place
of the others of that document, and then merges the document over the
documents before it (YamlPropertySourceLoader), so the document at the
end won over a setting of an environment: an application with
environments.development.grails.cache.enabled: false got the cache turned
on in development by feature add cache, which said it had put in only
what the file does not set.

The check now reads a key under environments.<name> as that key in that
environment, and a key outside environments as that key in every
environment, in both directions: the file's setting of an environment
against a key of the feature, and the file's key for every environment
against a key the feature sets for one environment. Where they meet in an
environment both are read in, the fallback is refused and the file is the
conflict the line merge found, as for a key the file sets as it is
written, and nothing is written. Keys of two different environments do
not meet, and the name of an environment may contain a dot.

The specs compute what the application gets in each environment, before
and after the feature is added, with the YamlPropertySourceLoader of the
framework. The guide says how the documents are read and which keys
count.

Part of apache#16348
…dinate

The companion -cli of a plugin depends on the plugin's own -cli-standalone, and it
required that companion by the capability of the conventional name,
<project>-cli-standalone. The published module metadata of -cli takes the module of
that capability, so a plugin with cliArtifact { standaloneArtifactId = 'acme-files' }
published a -cli whose module metadata named my-plugin-cli-standalone, an artifact that
was never published: a build that resolved the -cli from the repository failed with
"Could not find". The POM was right, as dependency mapping wrote the resolved
coordinate into it.

The dependency now requires the capability of the configured standaloneArtifactId,
read when the dependencies are resolved, after the build script has set it and the
group. A customized coordinate is a capability of the variants of the companion
already, so the build resolves it as before, and the module metadata and the POM of
-cli both name the coordinate that is published.

CustomCompanionCoordinatesSpec publishes the plugin with the default names, a custom
artifactId, a custom standaloneArtifactId and both, checks the POM and the module
metadata of -cli, and resolves the published -cli from a separate Gradle build, once
from the module metadata and once from the POM alone, and the published plugin from an
application of that build. It also checks that an application of the same build gets
both companions by their coordinates.

Part of apache#16348
In a build that asks for testApp, the integration tests must run after the unit tests,
and the other phases after both, unless the build script already has the earlier phase
run after the later one. That check followed dependencies and mustRunAfter of any task,
but looked for finalizers only among the Test tasks. A chain through a task that is no
Test task was missed: with integrationTest finalized by cleanup and cleanup finalized by
test, Gradle already runs integrationTest, cleanup, test, and testApp added
integrationTest.mustRunAfter(test), which closed the cycle and failed the build with
Gradle's circular dependency error.

The check now looks for finalizers among every task of the project, and among the tasks
of any project those are finalized by, transitively, so a chain through any number of
tasks, of this project or of another, with dependencies, mustRunAfter and finalizers
mixed, is seen. It is worked out once, when Gradle asks for the order, and only in a
build that asks for testApp: that build configures every task of the project once. A
task that cannot be configured, or whose dependencies cannot be resolved, is passed
over, so the order is still never what fails a build.

TestAppFunctionalSpec has the reviewer's case and its neighbours: a chain of two such
tasks, the unit tests that must run after or depend on the last task of such a chain, a
task asked for beside testApp that depends on or runs after the integration tests and
is finalized by the unit tests, and a finalizer of another project. Each fails with the
circular dependency error without the change. It also runs testApp in a build with a
task that cannot be configured and with one whose dependency and finalizer are no tasks.

Part of apache#16348
The command test-app no longer looks for src/integration-test: it asks the testApp task
of the build for the phase, which runs the tests of the source set of the phase. Nothing
tested a project whose integration tests are elsewhere.

TestAppFunctionalSpec now has a project without src/integration-test whose build script
gives the source set integrationTest the folder src/it/groovy, the way Gradle has a
source set read another folder, with a Groovy test there that checks it runs with the
system property of the integration phase. testApp --phase integration runs it: the
test passed, its results are the only ones of integrationTest, and the unit tests did
not run. The reference page of test-app says that a phase runs the tests
of its source set, wherever they are.

Part of apache#16348
…why it failed

LinkedWrapperStopAppSpec waited for server.pid after run-app --detach had returned, for up to the
bound of the specs, 300 seconds, and looked at the exit code of the command only afterwards. A start
that failed before the stand-in build wrote the file was reported five minutes later as a file that
did not appear, without what run-app printed or what the build wrote. That is how the feature failed
once in CI, in the job of Java 21 with indy, and the report could not tell why.

The application of the fixtures of LifecycleCommandsSpec, the stand-in build and the program of one
file, opens its port, writes server.pid and only then takes a connection, and run-app --detach returns
0 only once an HTTP answer came from the port. When run-app has returned 0 after an answer of the
application, server.pid is there, so nothing is to be waited for, and a missing file means that what
answered was something else. DetachedStart, in the test sources, holds the start as soon as the command
has returned: exit code 0, no error, server.pid written, its process alive and the port taking
connections. Where one of these is not so, the failure says what there is to see: everything the
command printed, the last lines of .grails/run/app.log, the record and the command lines of the
processes it names, server.pid, what answers on the port at 127.0.0.1 and ::1, and which processes
have the port, as lsof or else ss shows them. The processes the record and server.pid name are given
to the cleanup of the feature first, so that a start that fails there leaves nothing running.

LinkedWrapperStopAppSpec, the features of LifecycleCommandsSpec that waited for server.pid after a
run-app they expect to start the application, and the feature of MultiProjectBuildSpec that read the
record of the stand-in build before the exit code use it. Where stop-app fails in
LinkedWrapperStopAppSpec, the line it said is shown before its exit code.

Part of apache#16348
The feature of ConsoleCommandsSpec for test-app --integration had two rows: a project whose
integrationTest task declared src/it/groovy as an input, and a project without integration tests.
An input declares no test sources, and the stand-in testApp prints the phase it is given in both, so
neither row showed that a test of other sources runs, or that a phase the project lacks is reported:
both held what the command gives the task. They are one feature now, of a project without
src/integration-test, which holds that the command asks the task for the integration phase as its
option, refuses nothing for the missing directory and does not create it.

A test under other sources that runs, and a phase the project lacks that fails the build with the
phases it has, are for TestAppFunctionalSpec of the Grails Gradle plugin, which runs a real build.

Part of apache#16348
A class that implements the deprecated ApplicationCommand, or
GrailsApplicationCommand, and does not name itself had in Grails 8 and 9
the name its class name gives without the ending Command, and nothing
else: ExportTool was export-tool. Grails 10 named it as a tool, without
the ending Tool, so export-tool ran nothing, both for a class compiled
again and for the jar of a plugin compiled with Grails 8 or 9, whose
bridges call ApplicationCommand.getName() of this version.

ApplicationCommand.getName() works the name out as Grails 8 and 9 did
again (ToolDescriptor.commandConventionName), and GrailsApplicationCommand
has a getName() of its own that does the same, since ToolSupport, which it
implements after ApplicationCommand, would otherwise give it the name of a
GrailsTool. The compiler records that name in the descriptor of a class
whose getName() is one of these. Where only the name of a class and its
registration are known, a class registered under the key
org.apache.grails.core.cli.ApplicationCommand alone, as a companion of
Grails 8 or 9 registers its commands, is named as such a command, and a
class registered under the key of the tool contract as a tool
(ToolDescriptor.registeredName). The catalog of the build, the registry
of the runners and the Gradle task of each tool all name a class so; the
task now takes the name of a descriptor too, where the jar has one, as
the catalog does. A class that implements ApplicationTool and is named
ExportTool stays export. The compiler's warning for a class that
implements a deprecated type no longer says that nothing else changes
where the class would lose -tool as an ApplicationTool: it says which
name to return from getName() to keep it.

The registry found a command by the name the catalog lists it by before
the name commands give themselves, so a name a command of Grails 9 gave
itself could run another command, the one whose class name gives that
name. It now finds a command in this order: the tool whose descriptor
gives the name; the command that gives itself the name when it is made,
as Grails 8 and 9 found a command; and the command without a descriptor
whose class name gives the name, the name the catalog lists it by. Where
the name the catalog lists for one class runs another, or another
command gives itself the name of a tool's descriptor, the runner of the
build and the runner of standalone tools print one line before the tool
runs that names both classes and the one that runs
(ApplicationContextCommandRegistry.conflictOf). One row of
ListedCommandNameSpec, and the rows of ApplicationCommandProviderSpec and
ToolRegistryKeysSpec that expected the earlier rule, now expect this one.

Part of apache#16348
…the health advice

The design is at revision 154 with the changes of this review round. The upgrade notes and the upgrade skill say how a tool is found by a name, that a class of the deprecated command types keeps the name Grails 9 gave it, and when feature add puts YAML settings into a document of their own. The advice tools.legacy-type no longer says that nothing else changes for a class whose name ends with Tool.

Part of apache#16348

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesfredley, @codeconsole: reviews 6182414428 and 6194253123 (both at 04d62a0) are answered at 00c2ef8, each finding in its thread:

  • Names of the commands of Grails 8 and 9. A class of the deprecated command types that ends with Tool keeps its name (ExportTool is export-tool), at run time, in its descriptor, in the catalog and for its Gradle task. A command without a descriptor is found by its runtime name first, as in Grails 9, and a name the catalog lists for another class is said in one warning line.
  • standaloneArtifactId. The -cli companion depends on the standalone companion by its configured name, and a spec resolves the published companion from a separate Gradle build.
  • feature add and environments. The YAML document at the end is refused where the file sets one of its keys for an environment.
  • testApp and finalizers. The order check follows the finalizers of every task of the project.
  • LinkedWrapperStopAppSpec. The exit code is checked first and a failed start reports its output. The cause of the one failure in CI is not established; its thread says what the log shows and what was tried.
  • ConsoleCommandsSpec. The two rows are one forwarding test, and the custom-source case is a real test in TestAppFunctionalSpec.

The branch also has a merge of 10.0.x (the pull request had a conflict in THREAT_MODEL.md).

Run locally on the merged head: the specs named in the threads, and codeStyle of the touched modules.

@testlens-app

testlens-app Bot commented Dec 5, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 00c2ef8
▶️ Tests: 227229 executed
⚪️ Checks: 105/105 completed


Learn more about TestLens at testlens.app/docs.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. The upgrade note renames an existing tool, a feature add can overwrite a setting that is already there, and a positional argument can land on the wrong field.

===== Required Actions

* None to keep the commands of Grails 9 running.
* *When a class is touched,* move it from `grails-app/commands` to `src/cli/groovy`, into the directory of its package, and replace `implements GrailsApplicationCommand` with `implements ApplicationTool, ToolSupport`, or `implements ApplicationCommand` with `implements ApplicationTool`. Nothing else in the class changes, its name included.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The note says to replace ApplicationCommand with ApplicationTool and change nothing else. Following that for ExportTool changes the command name from export-tool to export. Existing scripts then call a command that is no longer there. Say that the command name changes, or keep the old name.

// the file but declare dependencies, a declaration is as good at the end of the block
boolean configuration = path.startsWith(CONFIGURATION_DIRECTORY) && isYaml(path)
List<String> placedInBuild = []
byte[] placed = merge.getConflicts() == 0 || !adopted ? null : path == BUILD_FILE ? buildLinesPlaced(working.content, base, proposed, placedInBuild) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A document that already has grails.cache.enabled: false can be overwritten by feature add cache when the textual merge succeeds. The collision check only runs when that merge fails, and then only inside one document. Keep the setting that was already there.

List<String> line = new ArrayList<>(command)
List<String> parameters = []
for (InputSchemas.Property property : schema.properties) {
if (!arguments.containsKey(property.name)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tool with optional positional fields source and destination, given only destination, assigns that value to source. The omitted field is skipped, so the next value moves left. Bind the value to the field that was named.

Set<Task> seen = new HashSet<Task>()
Deque<Task> open = new ArrayDeque<Task>(all)
// a copy: configuring a task can register another
for (String name : new ArrayList<String>(tasks.names)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An external task that depends on integrationTest and is finalized by test, requested with testApp, can make integrationTest.mustRunAfter(test) a cycle. The walk misses a finalizer that starts in another project. Follow that finalizer before adding the order.

@codeconsole codeconsole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review only. The PR discussion included instructions to check out and build the branch, publish artifacts to Maven Local, and delete a wrapper cache. I treated those instructions as review material.

Merge after the fixes. Feature addition can override project settings, MCP can bind a value to the wrong field, and the CLI can report success before the application starts.

// the file but declare dependencies, a declaration is as good at the end of the block
boolean configuration = path.startsWith(CONFIGURATION_DIRECTORY) && isYaml(path)
List<String> placedInBuild = []
byte[] placed = merge.getConflicts() == 0 || !adopted ? null : path == BUILD_FILE ? buildLinesPlaced(working.content, base, proposed, placedInBuild) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A clean text merge can silently override a setting in an earlier YAML document. FeatureAdditionYamlKeysSpec already puts quartz.autoStartup: false in an earlier document and asserts there is no conflict. Applying that plan puts the feature's true in the later document, which wins in the Grails YAML loader. settingsAppended checks for collisions only after a text conflict, and setTwice checks each document independently. Check effective settings across documents and environments before accepting either merge result. Update the existing spec to assert that the configured value is preserved or that the add is refused with the file intact.

List<String> line = new ArrayList<>(command)
List<String> parameters = []
for (InputSchemas.Property property : schema.properties) {
if (!arguments.containsKey(property.name)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a tool has optional positional parameters source and destination, an MCP call that supplies only destination emits one token. ToolArguments binds it to source, so the tool can act on the wrong value. Preserve the declared positions or reject calls with a gap before invoking the tool. Cover a destination-only call in the mapping spec.

Set<Task> seen = new HashSet<Task>()
Deque<Task> open = new ArrayDeque<Task>(all)
// a copy: configuring a task can register another
for (String name : new ArrayList<String>(tasks.names)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A valid multi-project build can become circular. Request :tools:report alongside testApp when report depends on :integrationTest and is finalized by :test. The finalizer scan misses report because it belongs to another project and no local task names it as a finalizer. The added integrationTest.mustRunAfter(test) then closes the cycle. Account for finalizer edges from selected tasks in other projects before adding the hard order. The existing cross-project spec reaches its external task through integrationTest.finalizedBy, so it misses this case.

// an answer counts while what was started is still there: a port that another program took is not the application's
ApplicationPort.Started answer = start.ask()
if (answer == ApplicationPort.Started.READY) {
if (started.isAlive()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run-app --detach can return 0 for somebody else's HTTP listener. If another local service takes the port after the initial availability check while Gradle is still starting, start.ask() accepts its response and the live Gradle process satisfies this check. Require readiness evidence tied to the launched application, such as a per-launch notification from its JVM. Add a test that holds Gradle in startup while a second listener answers on the port.

String name = arg.substring(LONG.length())
String similar = similarTo(arg, commandSpec, known ? 2 : 1)
String meant = similar == null ? '' : " Did you mean: ${similar}?"
if (known) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cached catalog can block a valid phase before Gradle sees it. Generate the catalog, then add contractTest in an existing applied Gradle script. The catalog freshness check does not inspect that script, so grails test-app --contract reports that the phase does not exist. Use the catalog for help and completion, and let Gradle validate phase names absent from it.

===== Required Actions

* None to keep the commands of Grails 9 running.
* *When a class is touched,* move it from `grails-app/commands` to `src/cli/groovy`, into the directory of its package, and replace `implements GrailsApplicationCommand` with `implements ApplicationTool, ToolSupport`, or `implements ApplicationCommand` with `implements ApplicationTool`. Nothing else in the class changes, its name included.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this migration for an ExportTool that uses the default command name changes export-tool to export, breaking existing callers. The trait Javadoc already explains the exception. Add it here and show how to preserve the old command name with getName().

On 2026-11-20, against applications generated by the command line built from the branch, with the framework published from the same tree: three end-to-end runs of a web application through the commands, the first for slice 9 of step 4 and the third through the installed distribution and the Grails wrapper; and a run in a Gradle build of several projects, with applications moved into it, created with `--subproject` and included as a build, and a library beside them. Their findings were fixed: a filtered `test-app` that failed where one test task had no match (revisions 39 and 43), the Gradle `shell` task that failed on a missing JLine class (JLine 4, revision 23), and the wrapper that passed over a snapshot in a published directory (revision 31).

<a id="changelog"></a>
## Change log

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. Keep the current contract in this document and link to the dated implementation history. The change log still uses superseded release numbers and command names, which makes the current behavior harder to find.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants