Skip to content

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

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

jdaugherty wants to merge 723 commits into
apache:9.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

Implements #16348 for Grails 9: 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 9.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 9 publishes no shell: without that pull request a Grails 9 project has no Grails commands and no Grails run configuration in IntelliJ IDEA. It switches a project of Grails 9 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 and 8 keep the shell. The contract it follows is upgrade note 51. It is to be released alongside Grails 9.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 9 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 or 8 (or of one Grails 9 did not generate) together with a baseline: the files Grails 9 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, 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 9 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 9 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 or 8, as project migrate does.
  • Why "tool". What an application or a plugin adds to the command line was called a command in Grails 8 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 8: 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 8 keep working; the bridge for those of Grails 7 is removed. grails-app/commands is compiled with src/cli and runs as before, 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 8, or an earlier build of Grails 9 Grails 9 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 9. 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 or 8 replaces itself once gradle.properties names Grails 9. 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 9 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 8 to 9 (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/upgrading90x.adoc; note 55 maps every command line of Grails 8 (the shell, the Forge CLI, plugin commands and scripts) to Grails 9.
  • 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 8

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

  • The wrapper updates itself: once gradle.properties names Grails 9, ./grailsw update-wrapper replaces grailsw, grailsw.bat and grails-wrapper.jar with those of Grails 9, 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 8 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 8 and Grails 9 command lines

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

Unchanged

Grails 8 Grails 9
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 8 Grails 9
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 8 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 8 Grails 9
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 8 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 8 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 8 Grails 9
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 8 Grails 9
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 8 Grails 9
— 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 or 8 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 8 Grails 9
./grailsw update-wrapper ./grailsw update-wrapper once grailsVersion names Grails 9: 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 8 Grails 9
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 8 Grails 9
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 8

Removed commands

Grails 8 Grails 9
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 8 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 8 for users of tools

  • A tool that declares its options or parameters refuses what it does not take (upgrade notes 72 and 74), 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 8 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 73).
  • The Grails wrapper writes its own messages to the standard error (note 71), 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 51).
  • 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 74). 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 8: 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 8 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 63). In Grails 8 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.
  • The SBOM of a module is written again when a dependency is added, removed or changes its version or its bytes: the resolved dependencies are inputs of the task that writes it.
  • 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 9 command line for projects of Grails 9 and later grails-intellij-plugin#477 for a Grails 9 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 Grails 9.
  • 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 9 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 9 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 68.96924% with 575 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.1285%. Comparing base (9f4e67b) to head (4ff0707).

Files with missing lines Patch % Lines
...grails/core/cli/compiler/ConstructionReader.groovy 60.9831% 128 Missing and 126 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.7143% 25 Missing and 11 partials ⚠️
...vy/grails/codegen/model/DomainFieldModifier.groovy 85.8696% 0 Missing and 26 partials ⚠️
.../core/cli/ApplicationContextCommandRegistry.groovy 64.2857% 5 Missing and 10 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                @@
##             9.0.x     #17114         +/-   ##
================================================
+ Coverage         0   71.1285%   +71.1285%     
- Complexity       0      48762      +48762     
================================================
  Files            0       2743       +2743     
  Lines            0     145597     +145597     
  Branches         0      29173      +29173     
================================================
+ Hits             0     103561     +103561     
- Misses           0      28589      +28589     
- Partials         0      13447      +13447     
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 82.0896% <ø> (ø)
...g/apache/grails/core/cli/compiler/ToolRules.groovy 87.3418% <ø> (ø)
.../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 2683 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:

CommandSpecBuildFailureSpec failed on the Java 21 and 25 Forge jobs with
an empty output: its process ended at once and left one behind that
wrote the line 3 seconds later. When a process ends, the JDK keeps what
is in its pipe and closes the pipe, so a later line reaches the reader
only if the reader was already in a read at that moment; on a busy
runner it was not. The specification now has the process write a
thousand lines and then the line before it ends, which the reader reads
to its end whenever it starts, and the comment of CommandSpec says what
the minute it waits for the reader covers.

Part of apache#16348
…name

On the Windows Forge job the temporary directory is named by its short
name, C:\Users\RUNNER~1, and plugin-info quotes an address with a ~ in
the command lines it suggests, as it does every argument a POSIX shell
could act on. PluginSuggestionsSpec and PluginDiscoveryContractSpec
expected the address of their index unquoted, so five of their features
failed there. They now work in the real path of the directory, which on
Windows has the long names; which addresses are quoted stays held by the
rows that give one a shell acts on.

Part of apache#16348
A download of the Grails CLI whose length the repository gave and that
ended early was reported as "it was cut off after N of M bytes" only
when the HTTP stream of the JDK returned its end, as it does on Java 21.
On Java 25 that stream throws IOException("Premature EOF") at the early
end itself, and a TLS or socket failure in the middle of the content
throws its own exception on every JDK, so the same defect read
"Premature EOF", "SSLException: (bad_record_mac) Tag mismatch" and so on,
depending on the JDK and on which layer noticed. The CI job on JDK 25
failed on the exact message for that reason.

The wrapper now counts the bytes it has read and, when an IOException
interrupts a download of known length before all of it arrived, reports
it was cut off after the bytes it got, with the exception of the JDK as
the cause. The behaviour (exit 1, no other repository asked) is
unchanged.

The specification of a download that breaks off has a second row in
which the proxy, after half of the jar, writes a whole TLS record that
no key decrypts: TLS fails before the HTTP stream can find the early
end, which reproduces on Java 21 what Java 25 does with the plain
cut-off.

Part of apache#16348
On Windows Files.move with ATOMIC_MOVE is MoveFileEx with
MOVEFILE_REPLACE_EXISTING: it opens the download with DELETE access,
renames it over the jar and closes it after. A JarFile opens with a
RandomAccessFile, which on Windows does not share deleting, so an open
of the jar while another wrapper is in that step fails with a sharing
violation, which Java reports as FileNotFoundException. A wrapper makes
that open when it looks at the jar after an update, when its own move
failed and it checks the jar that is there, and in the class loader it
starts the command line with. Each of them ended the wrapper with exit 1
("cannot be started", "cannot write to", "has no start class") although
the jar was whole. The CI job on Windows found it as a flake: the
specification of wrappers that download one version at the same time
saw "it does not open as a jar: FileNotFoundException" nine times in one
run, and had passed in the six runs of the job before, whose move and
open of the jar were the same.

StartClass now opens the jar through one method that, on Windows only,
tries an open that fails with FileNotFoundException again while the
file is there, every 50 ms for up to 30 seconds. load holds the jar
open that way while the class loader opens it, which keeps another
wrapper from moving a download into its place meanwhile; a jar that
does not open as one is still refused with the message it had. On
macOS and Linux nothing changes: there a file that is there and does
not open cannot be read at all.

A Windows-only specification holds the jar with a channel that does not
share reading, as the move does, and finds that defect and load wait
and succeed once it is let go. The guide says that a wrapper waits for
the move of another one.

Part of apache#16348
@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
A feature could not declare a dependency on another variant than the
default one. Ehcache publishes its build for Jakarta EE as the variant
with the capability org.ehcache:ehcache-jakarta, which a Gradle build
selects with requireCapability, and neither a feature of the framework
nor a feature pack could write that into the build file.

A Dependency now carries the capabilities it requires, and the build
file requires them in the closure of the dependency, before its
exclusions, on the one line exclusions are written on. Declaring one
dependency twice with different capabilities is refused, as it is with
different exclusions, since keeping either would drop the variant the
other asked for. A pack names them under capabilities of a dependency,
each group:name, and the summary of a pack that is not of Forge says
which capability a dependency is declared with.

Part of apache#16348
The feature declared org.grails.plugins:cache-ehcache:5.0.0-RC1, a
release candidate and the only release on Maven Central. Grails 9 does
not load that plugin: its classes need the classic call sites of
Groovy, groovy-callsite, which Grails 9 does not ship, and the plugin
finder skips a plugin whose class cannot be created, so the cache
manager stayed the ConcurrentMap one of the cache plugin. The plugin
also brings grails-cache to the runtime class path only, so a service
with @Cacheable did not compile in an application generated with the
feature alone. Nothing ran such an application.

The feature now requires cache and gives the application Ehcache 3
through JCache, in released versions the BOM manages: the Jakarta EE
variant of org.ehcache:ehcache, grails-app/conf/ehcache.xml with the
default template of JCache and an example cache, a class of the
application, JCacheGrailsCacheManager, a JCacheCacheManager of Spring
that implements GrailsCacheManager and creates a cache it does not have
from that template, keeping its values as they are, and the beans
jCacheManager and grailsCacheManager in resources.groovy. That bean is
what the cache plugin reads by name and what its guide says an
application replaces; Spring Boot's cache auto-configuration backs off
beside it, and the plugin has no setting for another cache manager.
The cache feature no longer writes grails.cache.cacheManager beside a
cache provider, which that setting does not choose. The feature is
offered for web and rest-api applications, as a plugin does not define
the beans of an application. The Hibernate second-level cache is
documented, not generated, as both Hibernate features turn it off.

EhcacheBuildSpec generates applications with Hibernate 5 and 7 and runs
integration tests in them that call a cached service twice, and check
that the second call is served from the cache Ehcache has for it and
that a cache ehcache.xml does not configure has its default template.

Part of apache#16348
The cache feature wrote grails.cache.cleanAtStartup, as Grails Forge of
Grails 7 and 8 did, but the cache plugin binds grails.cache.clearAtStartup
to CachePluginConfiguration and reads no other key for it, so the setting
did nothing. The feature also named the cache manager
grails.plugin.cache.GrailsConcurrentMapCacheManager, a class name the
plugin does not compare: it takes GrailsConcurrentMapCacheManager for
every value but GrailsConcurrentLinkedMapCacheManager, so the setting
chose the default only by accident, and the same form of the bounded
cache manager would not have chosen it. grails.cache.enabled is read as
written.

The feature now writes grails.cache.clearAtStartup: false and
grails.cache.cacheManager: GrailsConcurrentMapCacheManager, the names the
plugin reads and its guide documents; what an application does is
unchanged. CacheAutoConfigurationSpec binds the configuration properties
as an application does, and shows that clearAtStartup clears the caches
at startup and cleanAtStartup does not. ProjectMigrateGeneratedSpec shows
that an application another build generated with the earlier settings is
refused by feature add and project regenerate until project migrate
moves its record, that feature add then keeps those settings as a change
of the application, that cache-ehcache, which takes out the cache manager
line, is a conflict on them, and that both work once they are renamed.
The upgrade note and the skill say to rename the key, and what it does.

Part of apache#16348
The Jakarta EE variant of org.ehcache:ehcache asks for
org.glassfish.jaxb:jaxb-runtime with the range [3,3.1). Gradle resolved
it to the version the BOM manages, but a dynamic version has the build
of a generated application list the versions of the module in the
repository whenever its cache of dynamic versions has expired, so the
build depended on the repository answering even with every artifact
cached; the repository keeps its own BOM-bearing configurations free of
dynamic versions for that reason.

The feature now declares Ehcache without that jaxb-runtime, with the
exclusion in the closure that requires the capability, and declares
org.glassfish.jaxb:jaxb-runtime as runtimeOnly without a version, the
scope Ehcache needs it in, so it has the version Spring Boot's BOM
manages (glassfish-jaxb.version, 4.0.9 with Spring Boot 4.2.0). Ehcache
needs nothing else from the excluded module: jaxb-runtime brings
jakarta.xml.bind-api through jaxb-core, and an application without
Hibernate, which brings jaxb-runtime too, has it from this declaration.

EhcacheBuildSpec resolves the runtime class path of the generated
Hibernate 5 and 7 applications after their integration tests: no
dependency asks for jaxb-runtime with a range, the application's
jaxb-runtime has the version the BOM constrains it to, and
jakarta.xml.bind-api is there. FeatureAdditionPlacesSpec counts the
third place cache-ehcache changes build.gradle at.

Part of apache#16348
The configuration metadata of grails-cache listed
grails.cache.ehcache.ehcacheXmlLocation and grails.cache.ehcache.lockTimeout,
settings of the third-party plugin org.grails.plugins:cache-ehcache,
which Grails does not ship and cache-ehcache no longer adds. No class of
this repository reads them: grails-cache reads grails.cache.enabled,
grails.cache.cacheManager, and binds grails.cache.clearAtStartup and
grails.cache.caches to CachePluginConfiguration. An IDE offered them,
and the Application Properties reference, which is generated from the
metadata, listed them, as settings that do something.

The overlay no longer has them; every setting the plugin reads is still
there. CacheConfigurationMetadataSpec reads the metadata the build
publishes and holds it to the four settings the plugin reads. The
upgrade note of cache-ehcache says that the metadata no longer lists the
two.

Part of apache#16348
The specs of project migrate copy the applications that Grails 7.0.9 and
8.0.0 created from earlier-applications in the test resources, and change
and compare their lines as those versions wrote them, with LF. No rule of
the .gitattributes covered that directory, so the Windows runner, whose Git
converts text files to CRLF on checkout, gave the specs files those versions
never wrote. Four features failed there and nowhere else: the BootStrap
check turned the CRLF of the checkout into CR CR LF, and the conflict that
a line of the application's own in the BootStrap class is to cause was never
written, because the line was put after a line ending with LF that the file
did not have.

The directory is now kept with LF like the golden files, and the fixture
refuses a file with a carriage return, so a checkout that converts it fails
with that reason instead of with the assertions of the specs.

Part of apache#16348
A text file whose lines end with CR LF, as on a clone that Git checked out
for Windows, keeps its line endings when a feature is added, and the lines
of the feature get them too. The one exception was a BootStrap class that
is as Grails 7 or 8 generated it: feature add replaced it with the content
this version generates, which has LF, so in an application that project
migrate adopted on Windows that one file came out with other line endings
than the rest of the application. It now gets CR LF where every line of
the file had them, by the same rule the merge follows for the lines it
adds.

A new feature of ProjectMigrateBaselineSpec holds an application of each
earlier version, with CR LF in every text file but the wrapper script, to
the same application with LF: project migrate writes the same record and
takes no file for a change of its owner for how its lines end, and after
grails-spring-security and cache every file is what it is with LF, with
CR LF. Without the change the class with LF is the one file that differs.
It runs on every system, so the CR LF case no longer depends on how a
checkout ends its lines.

Part of apache#16348
The scripts of plugins are found in the jars of the class path by the entries of each jar, which is found by its directory entry or by its manifest. A jar with neither could not be listed, so a script was asked of it by a few names a command of that name usually has, and a file named otherwise, such as Create-Thing.groovy, was not found there. A jar without a manifest is no jar a build of a plugin makes: it is no longer searched, with or without an entry for the directory, and the guessing of names is gone. In a jar with a manifest a file named with a hyphen and capitals is found, which the specification now holds.

Part of apache#16348
A jar that has scripts in META-INF/commands and no manifest is not searched for scripts. The runner now names such a jar on the standard error, once for a jar, so that whoever built it sees why its script is not found.

Part of apache#16348
ForgeApiIntegrationSpec held that the features the Forge API lists for the
type rest-api-plugin do not include scaffolding. That was true when the type
was added, but a later change made the scaffolding feature selectable for a
REST API application and a REST API plugin, whose tools generate a REST
controller and JSON views there, as the guide and the upgrade notes say.
That change updated CreateRestApiPluginCommandSpec and the golden file of the
feature, and missed this specification, which failed in every Forge job.

The specification now expects scaffolding among the features the type can
have and not among its defaults, as CreateRestApiPluginCommandSpec does, and
still expects the asset pipeline, OpenAPI and Spring Security to be absent.

Part of apache#16348
StandaloneToolRunnerSpec failed in the coverage job because the standard
error of a forked tool, which must be the one line the runner says, also had
a warning of JLine that the history file in the home of the runner is
accessible by other users. The tool makes the console of Grails, which
created ~/.grails_history with the permissions the umask leaves, 0644 on the
runner, and JLine warns of such a file each time it saves the history, which
the console does in a shutdown hook. Whether the warning reached the standard
error depended on that hook racing the one that resets the handlers of
java.util.logging, and on the history file of whoever runs the specs.

GrailsConsole now creates the history file readable and writable by its
owner only where the file system has POSIX permissions, as JLine creates one
itself, since what is typed at the console can be a secret. A user who runs a
standalone tool that makes the console, such as generate-all, no longer gets
the warning at the end of every run for a file Grails created.

The forked JVMs of StandaloneToolRunnerSpec and DeclaredToolArgumentsForkSpec
had no home of their own: their console read and wrote the history file in
the home of whoever runs the tests, and created it there when it was
missing. Each now gets a home in its temporary directory. The four specs of
scaffolding and the Spring Security plugins that fork such tools already gave
theirs one. StandaloneToolRunnerSpec also checks that the history file the
console creates is readable by its owner only; with the earlier console it
was rw-r--r--.

Part of apache#16348
GradleCommandSpec failed in one Forge job: the CLI, started as a program
that runs grails gradle build, was ended while the wrapper ran, and its
output had what the wrapper wrote but not the line that Gradle was stopped.
The specification reads the output once the process has ended, and the CLI
writes it itself, so the line was not late: it was never written. GradleRunner
started the wrapper and added the shutdown hook that says the line and stops
the wrapper only afterwards. A JVM that was ended in between ran no hook of
it, said nothing, and left the wrapper and what it started running. With a
pause of three seconds put between the start and the hook, the feature failed
every time, as in CI, and the wrapper and its child were left behind.

The hook is now added before the wrapper is started, and the wrapper is
started while the hook cannot read what was started: a JVM that is ended
while the wrapper is being started stops it once it has started, and one
that is ended before starts none. With the same pause put after the start,
the feature passes. The wait for the wrapper is a method of its own, and does
what it did.

Part of apache#16348
ToolsGeneratedApplicationSpec failed in the Java 25 job: a standalone tool
that grails runs as a process of its own, without Gradle, wrote four lines
of Java on the standard error after the one line the command says. From Java
22 on, Java warns the first time code of the class path calls a restricted
method without native access, and JLine, which the console of Grails uses,
calls MemorySegment::reinterpret where it uses the foreign function API, as
it does from Java 22 on. The scripts of grails start the command line with
--enable-native-access=ALL-UNNAMED, and the Grails Gradle plugin gives it to
the processes of a build on Java 24 and later, but a standalone tool was
started without it, so a user of Java 22 or later got the warning each time
such a tool ran.

The Java a standalone tool is started with now knows its version, as its
release file says it, and a Java 22 or later is given the option before the
class path. An earlier Java does not warn, and a Java whose version is not
known is given nothing it might not take. A new feature of StandaloneToolsSpec
starts the tool with a JAVA_HOME of each version that writes down the options
it is given, and the guide says how the tool is started.

Part of apache#16348
McpCallSpec failed in the Java 25 job: the first build of the feature on the
build lane timed out in the client after the round of 30 s that InProcessMcp
gives a call. The feature holds that build open while it starts a second
build, calls project_show and waits, for up to 60 s, until the second build
is told that it waits; on a slow runner that took longer than the round, and
the call that was held open was given up on by the client. Its calls also ran
on the common pool of the JVM, which other work of the test JVM shares.

Looking at how the lane keeps the order showed that it did not keep it. A
call that waited took a fair semaphore with a time, to be told every so often
that it waits; when the time was up it left the queue of the semaphore and
came back behind the calls that had come after it. Two calls that waited
longer than that took the lane in either order. With a third build started
after the second was told that it waits, and the first released just after
the second was told so again, the third ran first. The guide says that the
calls of a lane wait in the order they came.

The places of a lane are now a queue of their own: a call that waits keeps
its place while it is told, at once and then every so often, that it waits,
and is told so only once it is in the queue. A call that is interrupted
leaves the queue and has taken nothing, as before. The order is that in which
the calls reach their lane, each on the thread of the protocol's library that
runs it: of two calls that arrive at the same moment, the server cannot tell
which came first.

The feature now holds the build open on threads of its own, with a round
that lasts as long as its bounded waits may. It starts a second build, and a
third once the second is told that it waits, waits until both have been told
so twice, and holds that the builds ran in that order and that a call is not
told that it waits once it runs. The run with the third build released at
that moment fails with the earlier lanes and passes with these.

Part of apache#16348

@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 command file named with a hyphen and capitals is still not found in a jar.

}
}
String path = connection.jarFileURL.path
if (jar.manifest == null) {

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 jar has META-INF/commands/Create-Thing.groovy and a directory entry, and it has no manifest. The command create-thing is not found, because the jar is skipped before the name is matched. Look in that jar.

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.

This is intended. A jar without a manifest is not searched for scripts, whether or not it has an entry for META-INF/commands: every jar a build makes has a manifest, so a file without one is not the jar of a plugin, and I would rather not run a script out of it.

What the head does (ce2e646, 2f28414):

  • A jar with a manifest is searched by its entries, also when it has no entry for the directory. The name of the file gives the name of the command whatever its capitals, so Create-Thing.groovy and CREATE-thing.groovy are both create-thing. ScriptCommandRunnerSpec has rows for both.
  • A jar without a manifest that has scripts under META-INF/commands and an entry for the directory is skipped, and one line on the standard error names the jar and says why. That is your case.
  • The earlier fallback that asked a jar it could not list for create-thing.groovy, CreateThing.groovy and createThing.groovy is removed, so there is no list of names left to add Create-Thing.groovy to.

One case gets no line: a jar with neither a manifest nor an entry for the directory is in neither class path lookup, so the runner never sees it; the command is reported as not found.

The guide says so in "Creating Custom Scripts".

@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 command file named with a hyphen and capitals is still not found in a jar.

}
}
String path = connection.jarFileURL.path
if (jar.manifest == null) {

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 jar has META-INF/commands/Create-Thing.groovy and no manifest. The command create-thing is not found, because the jar is skipped before the name is matched. Look in that jar.

…r scripts

The specs of the command line waited for what a stub of the Gradle wrapper did by
sleeping for a fixed time or by polling a file with a bound of their own: 30, 60,
120 or 300 seconds, chosen spec by spec, some of which were also the time the
event was expected in. On a slow, shared runner such a bound is the failure.

SpecWaits, in the test fixtures that test-core shares, is the one bound of every
wait: five minutes, times the factor the environment variable
GRAILS_SPEC_WAIT_FACTOR or the system property grails.spec.waitFactor names, so
that a slower runner raises every bound in one place. Its waits block on the
event itself (a latch, a future, a thread, a process, a condition) and fail with
what was waited for. eventually returns nothing, as PollingConditions does, so
that a then block does not take it for a condition of its own.

Handshake is what a stub script and a spec tell each other through a directory
of files, which Linux, macOS and Windows all have: the script says the steps it
is at, each a line added in one write, and holds at a step until the spec
releases it; the spec blocks until a step was said. CommandSpec gives each
feature one, made on whichever thread first asks for it, writes stub wrappers
with its functions, and releases and removes it after the feature, so that a
script a failed feature left holding ends. A script that holds instead of
sleeping 300 seconds neither ends by itself before the spec looks nor outlives
the spec.

The fixtures that had their own bounds use the shared one: CommandSpec, whose
wait for a whole generated build keeps twice the bound and reads the output to
its end once the build has ended; InProcessMcp, whose calls had a round of 30
seconds that a call a spec held open could outlast; McpLeftovers; the stub tool
that blocks until it is interrupted. IsolatedGradle records the instant each
daemon began beside its number and ends only a process that began then, so that
closing the fixture can no longer end another build's daemon that was given a
number a daemon of the fixture had.

Part of apache#16348
Several specs waited out a duration of the command line in real time, or raced it
against what they looked at: the ten seconds GradleRunner gives a process before
it ends it by force, the five seconds grails mcp waits for its calls at the end
of its input, the time run-app --detach gives an application to answer, and the
thirty seconds stop-app and the shell wait at the port of an application or for
a run-app that was asked to end it.

Each class gets a hook for a specification, as its others are: a static volatile
value that is null unless a specification sets it, and is read where the
duration is used. GradleRunner.setStopSeconds replaces the time every caller of
stop gives; McpLifecycle.setGrace replaces the grace of one reason, and graceOf
says which one applies; RunAppCommand.setReadyTimeUp replaces the clock that
says that the time to answer is up; StopAppCommand.setPortWait and setStopWait
replace the wait at the port and the wait for a run-app. What the commands say
keeps the seconds they give, and nothing changes where no specification sets a
hook.

Part of apache#16348
StandaloneToolProcess started the JVM of a standalone tool and added the shutdown
hook that stops it only afterwards, as GradleRunner did for the Gradle wrapper
until recently. A command line that was ended in between ran no hook and left
the tool running. The hook also never said that the command was stopped: the
thread of the command said it only if it got there before the JVM had ended,
which it usually does and need not.

The hook is now added before the tool is started, and the tool is started while
the hook holds what it reads, as in GradleRunner: a JVM that is ended while the
tool is being started stops it once it has started, and one that is ended before
starts none. The line that the command was stopped is said once, by the hook or
by the thread of the command, whichever comes first, before what does not end
by itself is ended by force.

StandaloneToolsSpec runs the command line as a program with a tool that holds
until it is released, ends the program, and holds that it ended with 143, said
that the command was stopped, and that the tool is gone, though nothing released
it. The earlier StandaloneToolProcess usually passes it, its thread of the
command being quicker than the end of the JVM. With a pause of six seconds put
between the start of the tool and what follows it, the feature failed with the
earlier code and passed with this one, as with the fix of GradleRunner.

Part of apache#16348
…time

The MCP specs cancelled calls with a client timeout of one to five seconds, which
on a slow runner could come before the build had started or the generator had
been entered, so that what the feature looked at had not happened; held builds
with sleep 300 or a generator with a sleep of three seconds; and waited with
bounds of 30 or 60 seconds of their own.

A call a feature cancels now runs on a thread of the feature's own, and the
feature interrupts it once the call is where it wants it: once the build said
that it has started, once the client was told that the call waits for its lane
or of the line the build wrote, once the handler runs it. The SDK's client then
tells the server that the call was cancelled, as a client that cancels does. The
generator of the generator-lane feature holds until the next call is told that
it waits for it, and records an interrupt. The stubs say their steps and hold
through the handshake instead of sleeping.

The features of a build that does not end when it is cancelled raced the server
giving up on it, one second after the cancel, against GradleRunner ending it by
force ten seconds after it was asked; they now have the build not ended by force
while they run, and release it at their end. The grace of the end of input is a
second in the feature that holds that the server waits for it, and the bound of
every wait in the one that holds that a signal does not; a feature that holds
that the second of two shutdowns waits looks at the state of its thread instead
of giving it half a second. Every bound is the shared one; the spec timeouts of
60 and 30 seconds are 600.

Part of apache#16348
…bound

The specs that run a stub of the Gradle wrapper, an application of a fixture or a
program from the console waited for a pid file with PollingConditions of their own
bounds, and had the stub sleep 60 to 300 seconds to stand for a build that does not
end: a stub that ends by itself before the spec looks is a race on a slow runner.
Some waited out a duration of the command line in full, thirty seconds for an
application that does not answer, and others gave it a time to answer of 30 seconds
that a slow runner can need for the start alone.

The stubs say their steps and hold through the handshake, or end only when they are
ended (tail -f /dev/null, a loop, a latch nothing opens); the features block on the
steps, on the end of the processes they started, and on what a command wrote, with
the shared bound. A real build that is to be cancelled holds its task on the
handshake instead of sleeping three minutes. run-app is given the shared bound to
answer in where the application is to answer, and where it is not, the time is up
once the application of the fixture has started, or has been asked, so that the
build is surely running when it is given up on. The wait at the port of an
application that does not end, and for a run-app that does not end it, is a second.
The application of the fixture writes down each request it was sent, so that the
feature of an application that says that it is starting holds that the command
asked twice and waits, instead of giving it two seconds.

CommandSpecBuildFailureSpec holds that the failed build exits with 1 by waiting for
its end, and not by the two seconds within which the message says the exit code; its
other features wait for the step of their stub instead of five seconds, and hold
that the process is still there instead of a time. Where time itself is what a
feature holds, a sleep stays with a comment that says so: a process that ignores
the interrupt is still there a while after it was sent it, and the application of a
fixture takes a while to shut down. Spec timeouts below the bound are 600 seconds.

Part of apache#16348
…shared bound

ToolingApiContinuousBuildSpec failed under load because the continuous build did not
run again within 120 seconds of the change to src/watched.txt: ran.txt held only the
first build. The change was written while Gradle watched: ContinuousBuildActionExecutor
adds its listener of file events before the build and calls afterBuildFinished on the
file system before it says that it waits for changes. Gradle reads no change of a file
but from the events of the system: the Tooling API's notifyDaemonsAboutChangedPaths only
invalidates the virtual file system of the daemon (HandleInvalidateVirtualFileSystem)
and starts no build, and an event of the directory of an input, which is what an
overflow of events becomes, is not taken for a change of the input (BuildInputHierarchy).

On this macOS computer, fseventsd uses a whole processor. A probe that watches a
directory as Gradle's watcher does saw the event of a write 0.3 to 5 seconds late with a
few builds running, and the last event of a burst only once other writes of the
directory followed. While the whole suite ran at 12 forks, most events did not come
within 20 seconds, and a lone write not within 40 seconds, other writes of the directory
notwithstanding. The scenario of the spec, run with the Gradle command line against a
daemon of its own beside the suite, lost the change for 150 seconds in one run of four,
and as often with another file of the project written twice a second after the change,
which is why the feature does not do that.

The feature now waits for the build of the change with the shared bound, the event
itself being what it waits for. The feature of the connection that is given up on closes
it after one second instead of thirty, and holds that the close returned, instead of
that it took less than 120 seconds. A system that delivers no event for minutes the spec
cannot make deterministic; the feature then fails at the bound, and says what it waited
for.

Part of apache#16348
The remaining specs of the command line and test-core waited for processes, latches,
futures and threads with bounds of their own, and gave the code they test durations
that are not what the feature holds: an answer of a repository 30 seconds, a whole
file 60, a catalog 30. Their waits now have the shared bound, and a duration that is
not what a feature holds is the bound as well, so that the duration that is held,
two seconds or 500 milliseconds, is told apart from the others by far more than a
slow runner takes.

A repository or a catalog that does not answer waits on a latch that only the end
of the feature opens, for the bound at most, instead of sleeping two minutes; the
feature holds that the command returned before the bound. The test of the
generated application in test-core waits as long as before for whole builds, raised
by the factor of the bound, and on a latch where its test runs until it is ended.
CommandSpec of test-core loses two helpers nothing called.

Part of apache#16348
The descriptor of a tool that is written by hand is compared byte for byte with what the compiler writes for the tool. The rule that kept such files with LF named META-INF/grails-commands, where descriptors were before they moved to META-INF/grails-tools, so a Windows checkout gave the descriptor of config-report CR LF and ToolDescriptorWriterSpec failed there.

Part of apache#16348
StandaloneToolRunnerSpec failed in the Java 25 jobs on Ubuntu and Windows:
the standard error of the JVM it starts for a tool that makes the console
began with the four lines in which Java warns that JLine called a restricted
method of the foreign function API without native access. Java warns of that
from Java 22 on. The grails command line gave the option to the standalone
tools it starts from Java 22, but the Grails Gradle plugin gave it to the
processes of a build, which run the other tools, the scripts and the shell,
only from Java 24, and the specifications that start a tool runner the way the
command line or a task does started it without the option.

The rule is now in one place both read, JvmOptions in grails-gradle-model:
--enable-native-access=ALL-UNNAMED for Java 22 and later, nothing for an
earlier Java or one whose version is not known. The command line gives it to a
standalone tool, the plugin gives it to every Test and JavaExec task from Java
22 on, and GrailsGradlePluginJavaCompatSpec now expects it for a toolchain of
Java 22 and 23 as well, with a new test project of Java 22. The specifications
that start a tool runner, StandaloneToolRunnerSpec, the fork specifications of
grails-console and those of scaffolding and the Spring Security plugins, start
the Java they run on with the options of JvmOptions for its version.

Part of apache#16348
McpCallSpec failed in the Forge Java 21 indy job: the result of a build that
failed did not have the line the build had written last, to its standard
error. The line had been kept, but in the middle of the text that was cut
away: the line that said what was left out counted 4,565 lines and 103,985
characters, which are the build's lines 48 to 4611 and that one line. The
Gradle wrapper wrote its output and its errors to two pipes, which two threads
copy into the one text a call keeps. When the build wrote its error, up to a
pipe's worth of its output was still unread, so the error was kept before the
end of the output the build had written earlier, and the end of the text,
which a failed call keeps, did not have it. Its error stream had been drained
before the result was built, and the cut kept the last line it was given.

Where the command writes to streams that keep one text, as each call of grails
mcp does, the Gradle wrapper, the process of a standalone tool and a program
of the console are now given one stream for their output and their errors,
which keeps them in the order the process wrote them. A new feature of
McpCallSpec has the wrapper write 20,000 lines faster than they are copied and
then why it failed to its errors: the build is told it has one stream, and the
result ends with that line. With two streams it was told so, and in one of
three runs the line was missing from the end, as in CI. The guide says so.

Part of apache#16348
A process that is run for a command that keeps one text of what is written has its errors in its output, so that they are where it wrote them. The specification of the streams of a call still expected the errors of Gradle and of a program apart from their output.

Part of apache#16348
… over the port

The server that answers on the application's port while it starts stopped
the JDK's HTTP server without a delay. Stopped that way, the server's
dispatcher can accept a connection while the stop is closing the
connections it holds, and that connection is then left open with no thread
to answer it. The client that made it waits for an answer that never comes:
the progress page, whose poll has no timeout, stops polling, and grails
run-app loses an ask to its read timeout. This is how a StartupProgressSpec
feature failed in CI: its first ask of the status path after the start was
released fell on the hand-off, and the read took the whole 30 seconds the
feature polled for. Asking a server that is being stopped from several
threads reproduces it within a few dozen stops, with the JVM holding the
taken connection open after the server's threads have ended.

The server is now stopped with a delay of one second, in which the JDK's
HTTP server lets the exchanges in progress end. It then closes the
connections only once its dispatcher has stopped taking them, so none is
left open. The exchanges end at once, as no answer waits on anything, so
the hand-off is no slower; a client that is slow to send its request holds
it for a second at most.

A new feature starts the application sixty times, each on a port of its
own, with clients asking as grails run-app does across every hand-off, and
fails when a request is left without an answer. Without the fix it failed
in every run, within the first fifteen hand-offs.

The waits of the spec are now on events, with one bound of five minutes,
times GRAILS_SPEC_WAIT_FACTOR, that only ends a wait for something that is
not going to happen. The fixed sleeps that gave a browser that should not
open the time to open now wait for every browser the JVM started to close,
and a bean is held for the time the report is to show only once it is
being created. The run-app probe reads the status line and the headers
alone, as grails run-app does, and a connection that is taken and not
answered fails it instead of reading as no answer.

Part of apache#16348
@jdaugherty
jdaugherty force-pushed the feat/16348-one-generator branch from 5c3c52b to 599acc8 Compare November 28, 2026 16:13

@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 command file named with a hyphen and capitals is still not found in a jar.

private URL pluginScript(String name) {
Map<String, Place> places = new LinkedHashMap<String, Place>()
Set<String> withoutManifest = new TreeSet<String>()
for (URL each : Collections.list(classLoader.getResources(CLASSPATH_LOCATION))) {

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 jar has META-INF/commands/Create-Thing.groovy and no directory entries. The command create-thing is not found, because this looks only in a directory or a manifest. Look in that jar.

…cesses

Four StartupProgressSpec features that check that a start opens no
browser, or no second one, waited for every child process of the test
JVM to exit before reading what the recording browsers wrote. On the
Windows runner a child of the test JVM never exits while the JVM runs,
so each of them waited out the five minutes of the bound and failed with
a TimeoutException. One of them, the feature for a start that is not
asked to open a browser, opens none at all and still timed out, so the
process waited for was none of the browsers. Which process it is the
CI log does not say; a Windows console process has a conhost.exe child
for as long as it runs, and the JVM's children are not the browsers'
own business either way.

The application says in its log, at debug, each time it has started a
browser, in the step of the start that opens it. The spec now turns that
logger on for its tests and counts those lines once the start has got
past that step: none while the beans are created when the page is not
served, none for a start that is not asked to open one, and one for a
start that opens one on the page and is restarted. What a recording
browser writes is still waited for in its file. Nothing waits on a
process any more, so no other process of the JVM can hold a feature up,
and a failing count shows each launch with its command line.

Part of apache#16348
The progress page polled the status with a fetch that had no limit of its
own. A poll on a connection that is taken and never answered, as the
server of startup progress could leave one when it handed the port to the
web server, held the page for as long as the browser waits, and the page
stopped polling: it neither showed the progress nor reloaded once the
application was ready.

Each poll is now given up after ten seconds and counts as a missed poll,
after which the page polls again as it does after any other miss. The
status is answered at once, so only a poll that will not be answered
takes that long. The limit comes to the page in its configuration, and a
browser without AbortController polls as before.

Part of apache#16348
@testlens-app

testlens-app Bot commented Nov 28, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 4ff0707
▶️ Tests: 218254 executed
⚪️ Checks: 106/106 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. A command file named with a hyphen and capitals is still not found in a jar.

}
}
String path = connection.jarFileURL.path
if (jar.manifest == null) {

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 jar has META-INF/commands/Create-Thing.groovy and no manifest. The command create-thing is not found, because the jar is skipped before the name is matched. Look in that jar.

This branch has not been deployed

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

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants