Repository navigation
Make Grails Forge the one generator and grails the one command line - #17114
jdaugherty wants to merge 723 commits into
Conversation
|
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. |
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 ( 1. A real Grails 8 application, upgraded. Created by the released Grails 8.0.0 ( 2. A generated application, edited, given a feature, built and run. 3. The catalog, 4. A fresh wrapper from the staged distribution. In the application of journey 2, with only Java on the 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 72c18ebEach re-run by hand with the distribution of 72c18eb:
Verification at 72c18eb, besides the runs above: |
A tour of this change, by common scenarioWhat this pull request changes for a user, scenario by scenario, with the class that implements each. Links are pinned to The big pictureGrails 8 had two command lines (the Grails shell with profiles, and the Forge CLI). Grails 9 keeps Forge, calls it
Code: 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 defaultsWhat's different:
What a feature looks like now, e.g. 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: trueA 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. Scenario 2: What's in the new project (
|
| 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-jobneedsgrails-quartz;create-restful-controlleronly in REST types;create-functional-testwrites 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 BookSpecwritesBookSpec.groovy, notBookSpecSpec.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 verbatimtest-appnow includes functional tests, the most likely surprise. Code:TestAppTask.- The environment goes after the command;
prod waror a leading-Dis refused. run-app --detachreturns once the app answers on its port (read fromapplication.yml); with the startup-progress page, a failed start is reported at once.stop-apponly stops whatrun-appstarted (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_DIRECTORYfor 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-updateHow 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 requiredHow it works (FeatureAddition, ThreeWayMerge, ProjectTransaction):
- Replay. Generate the app twice in memory: from the record, which must reproduce
.grails/baselinebyte for byte, and with the new feature. - 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.
- 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 CIproject 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 cleanWhy 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 quitBuilds 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
- Exit codes: 0 done, 2 command-line mistake (nothing ran), 1 anything else.
--plain-output,--non-interactive,help --json(every command, option, value and rule),--jsonon theprojectcommands;bin/grails_completionfor bash and zsh.- IntelliJ needs Support the Grails 9 command line for projects of Grails 9 and later grails-intellij-plugin#477 for a Grails 9 project. Without it, IntelliJ has no Grails commands for the project, because the plugin starts the removed shell.
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
- Record the Forge feature pack of a plugin version in the plugin index grails-plugins-metadata#326 has to be merged, and the index written again, before a plugin's feature can be selected by name; until then use the plugin's coordinates. Grails' own 61 packs don't depend on it.
- Neo4j can't combine with Hibernate 7 or Micronaut;
cache-ehcacheresolves to5.0.0-RC1and is only compile-checked; not yet verified against an ASF-staged release.
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.
How to test locallyThese steps build this branch into a
You need JDK 21 and 1. Build and installgh 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
Keep the four variables set in every terminal you test in. A generated application records 2. A new application, with the command linecd "$(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, exitA 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 4003. The Grails wrapper of that applicationenv 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-app4. A Grails 8 application, upgraded by its own wrapperStart from a Grails 8.0.0 application that has 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 compileCleaning uprm -rf "$GRAILS_WRAPPER_HOME"The 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
4100b57 to
cddda1a
Compare
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
left a comment
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.groovyandCREATE-thing.groovyare bothcreate-thing.ScriptCommandRunnerSpechas rows for both. - A jar without a manifest that has scripts under
META-INF/commandsand 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.groovyandcreateThing.groovyis removed, so there is no list of names left to addCreate-Thing.groovyto.
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
left a comment
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
5c3c52b to
599acc8
Compare
jamesfredley
left a comment
There was a problem hiding this comment.
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))) { |
There was a problem hiding this comment.
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
✅ All tests passed ✅🏷️ Commit: 4ff0707 Learn more about TestLens at testlens.app/docs. |
jamesfredley
left a comment
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
One generator, one command line
Implements #16348 for Grails 9: Grails Forge is the only application generator,
grailsis 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, isgrails-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, andplugin-infocannot name the feature a plugin is added with. The features of Grails itself, a pack named by its coordinates or by a directory, andlist-plugins/plugin-infofor 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.GrailsCliofgrails-shell-cliand 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 theMain-Classof thegrails-clijar (org.apache.grails.forge.cli.GrailsCli), takes the commands fromhelp --json, gives the environment where each command takes it, and runsrun-appas the Gradle taskbootRunof 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
grailsis the former Forge CLI, extended to do what the shell did in a project.grails-shell-cli, the seven profile artifacts,-t/--typeandGRAILS_PREFERRED_SHELLare gone.grails gradle ...,run-app --detachandshellalways use the wrapper.GRAILS_GRADLE_RUNNER(auto,process,tooling-api) overrides the choice andGRAILS_CLI_DIAGNOSTICS=truesays which way each command ran and why.create-app,create-restapi,create-plugin,create-web-pluginand the newcreate-rest-api-plugin. Most features are declarative feature packs (61 bundled); a plugin can ship its own insrc/main/forge, checked bycheckForgePackandforgePackTest. New among the bundled ones:grails-publishfor 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 nograils-app/views, which a new REST API plugin is.buildscriptamong 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.parametersare options of a feature, set with--feature-option FEATURE.NAME=VALUEon the create commands and onfeature add, read by the templates and recorded with the project.instructionsare printed once the application is created or the feature added, as plain text.artefactsgive 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 undersrc/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 asdatabase-driver, and the versions this release of Grails knows (versionOfForgeand 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").kind: presetnames 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.grails-bom(Hibernate 5),grails-hibernate7-bom, orgrails-neo4j-bomfor GORM for Neo4j, whose driver versiongrails-bomcannot hold. Combinations no BOM covers (GORM for Neo4j with Hibernate 7 or Micronaut) are refused with the reason.cache-ehcachegives Ehcache 3 through JCache with released versions the BOM manages (org.ehcache:ehcache, its Jakarta EE variant throughrequireCapability), agrails-app/conf/ehcache.xmland agrailsCacheManagerof the application inresources.groovy; it replacesorg.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-bommanages 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.validateMcpSdkVersionfails the BOM build when a Spring AI bump needs another SDK version, and names the version to set..grails/project.yml,.grails/forge.lock.ymland.grails/baseline/say how a project was generated and by which build of the generator.project showprints the command that makes the same application again;project regenerate --difflists what differs from what was generated. An interrupted change is ended file by file, never over a later edit.--jsongives a program each result with an outcome and a reason.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 listsays what a project has and what can be added. Three commands look without changing anything:feature find TEXTlists the features that have a text in their name, title, description or category;feature show FEATURE(alsofeature 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 difffeature addwould apply. The three take the pack options offeature 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 addafter an upgrade.project migratewrites 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 addthen 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 (theREADME.mdof a shell-created application) is left out and the feature added without it; the lines a feature adds tobuild.gradleare placed by the order of a Gradle build file where the merge finds no place for them (dependencies at the end of thedependenciesblock,apply plugin:andapply from:after the last such line, a pluginidat the end of thepluginsblock or in a new one afterbuildscript, 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 aBootStrap.groovythat 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 andproject migrate --forcewith the missing option writes it with one.project migratealso moves the record of an earlier Grails 9 version.grails project healthchecks 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;--strictalso fails on a warning and--jsonis for automation. It runs in a project still on Grails 7 or 8, asproject migratedoes.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 ofgrails(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 ofgrails mcpunder the same name.grailsis a tool, and the folder of its source decides how it runs.grailskeeps 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 insrc/cli(ApplicationTool) is compiled against the classes of the project and run by the build with the Gradle taskrunTool, with the application started around it unless it declaresboolean startsApplication = false. A tool insrc/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 theclitier exists, andgrailsCliis 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 NAMEdescribes 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 NAMEruns any tool with Gradle. See the three tables below.<artifact>-cli(fromsrc/cli,src/standaloneand the deprecatedgrails-app/commands) and<artifact>-cli-standalone(fromsrc/standalone, never depending on the plugin, published when the plugin has such a tool), without applyinggrails-plugin-cli. A plugin whose tools are all standalone publishes a-cliwithout classes that depends on its-cli-standalone, sograilsCli "org.apache.grails:grails-scaffolding-cli"keeps working. An application gets both by depending on the plugin, in the scopesgrailsCliandgrailsCliStandalone;grailsCliStandalonealone takes the standalone tools of a plugin without the plugin.grails-app/commandsis compiled withsrc/cliand runs as before,ApplicationCommandandGrailsApplicationCommandare deprecated subtypes ofApplicationTool, andrun-command,runCommand,run-script,runScript,runScriptCommandand the scripts insrc/main/scriptsare deprecated; each keeps working and warns once, naming tools.create-commandis refused in favour ofcreate-tool [--standalone].grails-core-cli-legacy,grails.dev.commands.*,grailsCliLegacyandlegacyCommandSupportare gone.s2-quickstart,s2-create-*,s2-create-acl-domains,init-oauth2,s2ui-*),query-tailand the scaffolding scripts are compiled tools, and the Quartz and Geb scripts are replaced bycreate-jobandcreate-functional-test. The scaffolding tools and six of the Spring Security tools are standalone tools in-cli-standalonecompanions;s2-quickstartandquery-tailare tools ofsrc/clithat do not start the application; thedbm-tools start it.generate-all,generate-controllerandgenerate-viewsgenerate what therest-apiprofile generated in a REST API application or plugin that has thescaffoldingfeature (a REST controller, its data service, their specs, and the JSON viewsindex.gson,show.gsonand_<name>.gson); they choose JSON views from the features of the project's record (views-jsonwithoutgsp), or from its views where it has no record, and--views=json|gspdecides 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-scriptis removed in favour ofcreate-tool).s2-quickstartwrites 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.@ToolOptionand@ToolParameteron the fields of a tool (or on the class, for a tool that reads its command line itself, wheretype = 'integer'andchoicessay that a value is a whole number or one of a few words; an@AnnotationCollectorshares a set),@ToolHintsfor what running it does (readOnlyHint,destructiveHint,idempotentHint,openWorldHint, the vocabulary of MCP and of Spring AI's@McpTool),boolean readsInput = truefor a tool that asks what is typed, andexecutionContext.resultfor a result as data.help NAME, completion,help --json, IDEs andgrails mcpread 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, andgrails NAME --helpshows 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 healthadvises the same (tools.description-missing,tools.arguments-undeclared,tools.hints-missing).create-toolwrites a tool that declares all of it. A tool that declares nothing runs as before.dbm-*tools of each Hibernate line,schema-export, the scaffolding and Spring Security tools,query-tail,generate-open-api.FrameworkToolsCompleteSpecfails the build when a tool of the framework lacks a description, hints or declarations. Twelve say that they change nothing, sograils mcp --read-onlyoffers them:query-tail,url-mappings-report, seven of thedbm-*-sqltools,dbm-validate,dbm-statusanddbm-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 mcpin a.mcp.jsonthe team commits (the optional Forge featuregrails-mcpwrites 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 ishelp --jsonof the directory, projected: the same document help, completion and the IntelliJ plugin read.refresh_toolshas the build list the tools again, and the list a client holds is updated when the build lists a new tool. Resources:grails://commands(thehelp --jsondocument, with diagnostics that say why something is not offered),grails://tools/{name},grails://project,grails://project/health, and the log of each call.grailsprocess. Each call runs onegrails --plain-output --non-interactivecommand 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_regeneratethat finds changed files,project_healthwith findings and a dry run offeature_addthat finds conflicts end with exit code 1 at the terminal, and over MCP return their document withoutisError. The tool list stays small (about 69 KB for the 39 tools of a new web application): the wholehelp --jsonentry of a tool is the resourcegrails://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.shell,console, a tool that declaresreadsInput), pass Gradle arguments of its own (gradleis 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-onlyoffers only the tools that change nothing. The threat model has a row for it.Where a tool goes
src/main,grails-app/*bootRun, the jar or warsrc/cligrailsCli, andsrc/standalonerunTool), with the application unlessstartsApplication = false<artifact>-cli, which depends on the plugin (and on its-cli-standalonewhen it has one)src/standalonegrailsCliStandaloneonlyjavaprocess started bygrails, no Gradle, never the application; also while the project does not compile<artifact>-cli-standalone, which never depends on the plugin; when all the tools of a plugin are here, its-clihas no classes and depends on itgrails-app/commands(deprecated)src/clisrc/cli, with a warningWhat each kind of tool runs with (the same at the terminal, in interactive mode and over
grails mcp)ApplicationToolinsrc/cli(the default)runToolBootStrapsrc/cli,src/standalone, and the scopesgrailsCliandgrailsCliStandaloneApplicationToolwithboolean startsApplication = falserunToolBootStrapStandaloneToolinsrc/standalonegrailsitself, as a plainjavaprocess; no Gradlesrc/standalone, the scopegrailsCliStandaloneand the tool API; nothing ofsrc/main,grails-appor the application's dependenciesNone of the three runs in the JVM of
grailsor ofgrails 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 intosrc/standalone; every other tool goes intosrc/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:dbm-*tools,schema-export,generate-open-api,url-mappings-report,config-reports2-quickstart,query-tailgenerate-*,create-scaffold-*,install-templates),s2-create-persistent-token,s2-create-role-hierarchy-entry,s2-create-acl-domains,init-oauth2,s2ui-create-challenge-questions,s2ui-overrideWhat is renamed
ApplicationCommand,GrailsApplicationCommandApplicationTool(+ToolSupport)StandaloneCommand,StandaloneCommandRunner(earlier 9)StandaloneTool,StandaloneToolRunnerGradleCommand(earlier 9)boolean startsApplication = falsegrails create-commandgrails create-tool [--standalone]grails run-command, GradlerunCommandgrails run-tool,runToolgrails run-script FILE, GradlerunScript,runScriptCommand, scripts insrc/main/scriptsrunToolgrailsCommandCatalog,.grails/cache/command-catalog.json(commands)grailsToolCatalog,.grails/cache/tool-catalog.json(tools)grailsStandaloneCommands,.grails/cache/standalone-commands.jsongrailsStandaloneTools,.grails/cache/standalone-tools.jsonMETA-INF/grails-commands/<class>.jsonMETA-INF/grails-tools/<class>.jsonGRAILS_LIST_COMMANDS; healthcommand-catalog.*GRAILS_LIST_TOOLS;tool-catalog.*GRAILS_LIST_COMMANDSis no longer read...Commandclasses...Toolgrails-core-cli-legacy,grailsCliLegacy,legacyCommandSupport,grails.dev.commands.*grailsCliStandalone, artifacts<artifact>-cli-standalone, manifestGrails-Cli-Standalone-ArtifactWhat an upgrade asks
implementationagrailsClilibrary that main code uses, or move that code tosrc/cli. Changegrails.dev.commands.*imports (project healthnames the files). RemovelegacyCommandSupport.grails-app/commandskeeps compiling and running, with warnings.-cli, and-cli-standaloneonce it hassrc/standalone, whether or not it appliedgrails-plugin-cli; tools undergrails-app/commandsare in-cliand no longer in the plugin's jar. Tests of a plugin's tools go insrc/test-cli. A plugin released for Grails 7 with commands needs a release for Grails 9.src/clionly, or apply or remove the plugin id. AgrailsCliline for a-cliwhose tools are all standalone, such asgrails-scaffolding-cli, keeps resolving.grails NAME,grails run-script FILE,grails run-command NAME,./gradlew runScriptand./gradlew runCommand ...keep working (the last four warn).GRAILS_LIST_COMMANDSis no longer read: setGRAILS_LIST_TOOLS.grails create-commandfails with exit code 2.run-app,stop-app,test-app.run-app --detachandrun-appin the console return when the application answers on its port (read fromapplication.ymlas 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-appstops only whatrun-appstarted. A plugin, or the application, can add options torun-app: it declares them inMETA-INF/grails-command-options.json(a name, a description and the application property the option sets), the build lists the valid ones, andrun-appshows 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-tailof Grails Data is declared so.test-appruns every test phase through one Gradle task,testApp;--unit,--integrationand--functionalselect phases, and a test name runs that test in whichever phase has it.grailsin a project) has the commands of the directory with completion and history;!programruns a command of the operating system as in the Grails shell;exitandquitend it.list-pluginsandplugin-inforead the plugin index of apache/grails-plugins-metadata (also offline, from a list bundled with the release), and are also commands of aplugingroup:plugin list [TEXT],plugin find TEXTandplugin show NAME(alsoplugin info), the same commands under a second name; every create command lineplugin-infosuggests creates what it names.GRAILS_PLUGIN_INDEXnames another index for every command that reads one.~/.grails/forge/packsunder 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.--offlineuses the kept jar, and--refreshfetches again. The directory can be deleted at any time.org.apache.grails.cli.DelegatingShellApplication, the one class of thegrails-clijar it downloads, which starts theMain-Classof that jar,org.apache.grails.forge.cli.GrailsCliofgrails-forge-cli. The wrapper of 7 or 8 replaces itself oncegradle.propertiesnames Grails 9. The packages of the command line do not overlaporg.apache.grails.cli, and both jars have anAutomatic-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.bin/grails_completionfor bash and zsh;help --jsondescribes every command and option, with values, defaults and rules. Command names can be shortened (cDC,rA, and in lower casera,sa,cdc); a short form that fits two commands runs neither and names the shortest form of each.project migrateandproject health.update-wrapper,project migrate, thenproject healthuntil--strictpasses).Where to start reading
grails-doc/src/en/guide/commandLine/tour.adoc.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.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 byCreatingToolsExamplesSpec; the design is section 3.9 ofgrails-forge/FORGE-CLI-DESIGN.md(revision 150).grails-skills/upgrade/skills/grails-upgrade/SKILL.md.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.
gradle.propertiesnames Grails 9,./grailsw update-wrapperreplacesgrailsw,grailsw.batandgrails-wrapper.jarwith those of Grails 9, to be committed. A tool that started the command line starts theMain-Classof thegrails-clijar; a program that callsGrailsCli.executecompiles againstorg.apache.grails.forge:grails-forge-cli.--profile,create-profileor other profile commands; aprofiledependency fails the build;grails.profileis not read.--featuresadds to the defaults and refuses unknown names;--exclude-featuresdrops a default; a profile of one's own becomes a preset.grails create-app --inplacewithout a name names the application after the current directory.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 fordevelopment; name another environment withrun-tool.testis no longer another name oftest-app;runandstopstill are other names ofrun-appandstop-app;exitandquitboth end the console;openis removed (!open FILEdoes it).stop-appstops only whatgrails run-appstarted.create-*commands fail when a file exists, unless--force; project templates are text and are not executed.create-controllerin a REST API project writes a controller withstatic responseFormats = ['json'], as the profile did.generate-all,generate-controllerandgenerate-viewsin a REST API application are the scaffolding plugin's commands and need thescaffoldingfeature (create-restapi --features scaffolding, orfeature add scaffolding);generate-allwrites no functional spec, andgenerate-unit-test,generate-functional-testandgenerate-resource-controllerare removed.feature add|list|find|show|diff,plugin list|find|show,project show|regenerate|migrate|health, andcreate-<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).--feature-option FEATURE.NAME=VALUE, beside--preset,--feature-pack-dir,--feature-pack-repository,--feature-pack-sha256,--feature-catalog,--refreshand--offline;feature addtakes the same pack options.create-scriptandcreate-commandare removed: a new tool is a class made withcreate-tool, insrc/cli, or with--standaloneinsrc/standalone; existing scripts and the classes ofgrails-app/commandsstill run, deprecated. In a plugin,create-toolputs a tool without a package into<package>.cli(<package>.cli.standalonefor a standalone one), so no package of a plugin is in two of its jars.GRAILS_LIST_TOOLS=falseturns that off;GRAILS_LIST_COMMANDSis no longer read).run-tool NAMEis for an environment, a name a built-in command has, and automation;run-commandstill works, with a warning.grailsClideclares it withimplementation:grailsCliis on the class paths of the tools and the tests, not on the compile class path of the application. A source that importsgrails.dev.commands.*importsorg.apache.grails.core.cliinstead (project health:tools.grails7-imports).~/.grails/settings.groovyis not read; proxies go toGRAILS_OPTS.UrlMappings, no controller, no views.grails-neo4j-bomin place ofgrails-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,Bookandcom.examplestand for your own names.Unchanged
grails create-app shopgrails run-appgrails compilegrails cleangrails wargrails create-domain-class Bookgrails add-property Book title:Stringgrails create-service Inventorygrails cDC Authorgrails statsgrails run,grails stopCreating an application
grails create-app shop --profile rest-apigrails create-restapi shopcreate-command per application typegrails create-plugin audit --profile rest-api-plugingrails create-rest-api-plugin auditgrails create-app shop --features mongodbgrails create-app shop --data mongodb--featuresno longer replaces the default featuresgrails create-app shop --features postgres,grails-quartzgrails create-app shop --exclude-features mockitograils-forge-cli create-app shopgrails -t forge create-app shopgrails create-app shop-tand--type: exit code 2GRAILS_PREFERRED_SHELL=forge grails create-app shopgrails create-app shopcd my-shop && grails create-app --inplacecd my-shop && grails create-app --inplacemy-shop, packagemy.shop); the Forge CLI of Grails 8 refused itcd com.example.store && grails create-app --inplacecd com.example.store && grails create-app --inplace com.example.storegrails create-app shop --profile com.acme:acme-profile:1.0.0grails create-restapi shop --preset com.acme:acme-preset:1.0.0Running, building and testing
grails test run-appgrails run-app -Dgrails.env=testtest,prod,devin front: exit code 2grails prod wargrails war -Dgrails.env=productiongrails -Dgrails.env=staging wargrails war -Dgrails.env=staging-Din front of the command: exit code 2grails run-app, thengrails stop-appin another terminalgrails run-app --detachgrails stop-appgrails --offline run-appgrails run-app -- --offline--grails test-appgrails test-appfunctionalTestincludedgrails test-appgrails test-app --unit --integrationgrails test-app -unitgrails test-app --unit-unitstill worksgrails test-app --functionalgrails test-app -- -x functionalTestgrails test-app BookSpecgrails test-app BookSpecgrails test-app -stacktracegrails test-app --stacktracegrails shellgrails shellgradle shell -qgrails rAgrails rAgrails rara,sa,cdc;grails help raends with the short formgrails cS Inventorygrails cS Inventorygrails cs Inventorycreate-service:create-script, whichcSalso fitted, is removedgrails crete-app shopends with exit code 1grails crete-app shopends with exit code 2Creating classes
grails create-controller Booka second time: file kept, exit code 0grails create-controller Book --force--forcean existing file fails the command (exit code 1)grails create-unit-test BookSpecwritesBookSpecSpec.groovygrails create-unit-test BookSpecwritesBookSpec.groovygrails create-controller Bookgrails project migrategrails create-controller Bookproject migratewrites its record,.grails, oncegrails generate-all com.example.Publishergrails generate-all com.example.Publishergrails generate-all Bookin a REST API applicationgrails feature add scaffoldinggrails generate-all Book--views=jsonwhere the application also has GSP viewsgrails create-audit-listener Orderartefactsof its pack), from the template undersrc/main/templates/features/<feature>/grails install-templatesgrails run-tool install-templatesgrails install-templatesnow copies those of thecreate-*commandsgrails create-script data-importgrails create-command data-importgrails create-tool data-importgrails create-tool --standalone data-importcreate-scriptandcreate-commandare refused (exit code 2, with a line that namescreate-tool); scripts andgrails-app/commandsare deprecated and still rungrails create-job Nightlygrails create-job Nightlygrails-quartzfeatureCommands of plugins and of the application
grails dbm-updategrails s2-quickstart com.example User Rolegrails url-mappings-reportgrails data-import orders.csvgrails prod dbm-updategrails run-tool -Dgrails.env=production dbm-updategrails dbm-update -Dgrails.env=productionruns in development, with a warning;run-commandstill works, with a warninggrails hello(a script insrc/main/scripts)grails hellograils create-tool hello)grails acme-sync ordersgrails gradle runScriptCommand --arg=acme-sync --arg=ordersMETA-INF/commands/acme-sync.groovy), until the plugin ships it as a commandFeatures and the record of a project
grails feature add database-migrationgrails feature add postgresh2grails feature add mysql --replacepostgres, which was asked for by namegrails feature add cache --dry-rungrails feature listgrails feature find databasegrails feature show postgresgrails feature info postgres--type rest-apifor a new application of that typegrails feature diff grails-quartzfeature addwould apply, on the standard output; exit code 0 when it can be addedgrails feature add com.acme:acme-audit-grails:2.3.0grails feature add com.acme:acme-audit-grails:2.3.0 --feature-option acme-audit.table=audit_logcat grails-forge-cli.ymlgrails project showcreate-command that makes it againgrails project regenerate --diffgrails project migrategrails feature add grails-quartz --dry-run.grailswith a baseline, andfeature addworks in it./grailsw update-wrapper./grailsw project migrategrailsVersionto a later 9.x: moves the record to itgrails project health --strictThe Grails wrapper and the version
./grailsw update-wrapper./grailsw update-wrappergrailsVersionnames Grails 9: replacesgrailsw,grailsw.batandgrails-wrapper.jar; commit them./grailsw update-wrapper run-app./grailsw update-wrapper./grailsw run-appupdate-wrappertakes no arguments: exit code 2grails -vgrails --version-vis--verbosegrails -versiongrails -VPlugins
grails list-pluginsgrails list-plugins securitygrails plugin-info spring-security-coregrails plugin-info spring-securityorg.apache.grails:grails-spring-securitygrails plugin listgrails plugin find securitygrails plugin show spring-securityplugingroup;plugin findrequires the text,plugin infoisplugin showInteractive mode
grailsgrailsgrails> quitgrails> quitgrails> exitgrails> !lsgrails> !lsRemoved commands
grails testgrails test-appgrails installgrails gradle publishToMavenLocalgrails-publishfeature of the plugin types does (create-plugin --features grails-publish)grails open build/reports/tests/test/index.htmlopen build/reports/tests/test/index.htmlgrails> !open build/reports/tests/test/index.htmlxdg-open,start), also with!in interactive modegrails list-profilesgrails helpcreate-commandsgrails profile-info rest-apigrails create-restapi --list-featuresgrails create-profile acme--presetgrails run app.groovygrails run-script app.groovygrails run app.groovyis refused with exit code 2 and says soSpeed
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=1for 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.grails --versiongrails create-controller Foograils create-appgrailsw --versionfeature add --dry-run,project regenerate --diffHow 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-appandstop-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,SpecWaitsin the test fixtures ofgrails-forge-cli), every wait has one bound that only ends a run that is stuck (5 minutes, timesGRAILS_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
| 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 FILEis the switch and the file. An option is written with two hyphens.dbm-status --verbosetakestrueorfalse.readsInputis refused under--non-interactiveand is given the terminal otherwise (note 73)../grailsw mcpis the protocol from the first run, the one that downloads the command line.help --jsonhas thetypeof every option and parameter, and for a tool itsoptions,parameters,hints,readsInputandincomplete, each only where it says something (note 51).grails-forge-clidepends 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 runsmcpcan exclude them. The CLI jar carries their licenses and notices (MIT for the SDK, MIT-0 for reactive-streams).dbm-*tools (note 74).dbm-generate-changeloganddbm-generate-gorm-changeloghonourexcludeObjectsandincludeObjects, asdbm-diffanddbm-gorm-diffdo. A change log name without an extension isNAME.groovyfor the default data source (Grails 8:NAME-dataSource.groovy) andNAME-DATASOURCE.groovyfor another, anddbm-create-changelogtakes such a name. The tools that write their output to a file (the ten-sqltools,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-rantakes no file name.-clicompanion 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 withgrails-spring-security-rest-gormor-grailscachethat uses@SecuredorSpringSecurityServicedeclaresimplementation "org.apache.grails:grails-spring-security".META-INF/commands, whatever the capitals of the file name (Create-Thing.groovyiscreate-thing). No script is taken from a jar without a manifest; such a jar that has scripts is named on the standard error.grailsis 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 forrunTooland 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.schema-exportsays what the tool does: both of its actions write the DDL script, and neither runs it against the database.Known limitations
feature addin 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 anapplication.ymlof another layout, lines added to a class. The conflict names the lines and writes nothing;feature add --diffshows the change to make by hand.scaffoldingfeature 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-serviceandgenerate-scaffold-allare listed although the classes they write need the plugin.run-app --query-tailis an option the command line artifact of Grails Data declares, sorun-apphas it once the project has been built; before that,grails run-app -Pgrails.gorm.queryTail.enableddoes the same.GRAILS_SAFE_DIRECTORY;run-tool NAMEruns it with Gradle. Standalone tools were not run on Windows.--feature-optionor a feature with commands is not read by agrailsof an earlier build of Grails 9.grails mcpspeaks MCP 2026-07-28 only. A client that starts with the olderinitializehandshake is answered with error-32022, which names the supported revision; the guide says which clients and settings speak it.grails mcpwas 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.json, notJSON), also for the tools that take any case at the terminal: the input schema has them as anenum.@AnnotationCollectoron 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 NAMEandproject healthstill say what a tool lacks).dbm-*tools that write change logs (dbm-generate-changelog,dbm-diff,dbm-create-changelogand the like) anddbm-db-doccan write outside the project; only the tools that write SQL, status and lock output are confined to it.What the original plan promised and this PR leaves out
Each of these is left out on purpose.
settings.xmland~/.grails/forge.yml. The command line fetches the jar of a pack fromGRAILS_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.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 migrateadopts instead: it writes the baseline in one step from the evidence it prints, and--forcecorrects it. One command and no interactive step serve an upgrade in a script as well as at a terminal.project migratedoes not edit build files. It writes.grailsand nothing else, so it can run before the project builds and never touches a file the user owns. Theprofiledependency is removed by hand: the build of Grails 9 refuses that line and says to remove it.rest-apiprofile and the functional spec ofgenerate-all.generate-unit-test,generate-functional-testandgenerate-resource-controllerare not carried over, andgenerate-allwrites no<Name>FunctionalSpec, which used the Micronaut HTTP client.create-unit-testandcreate-functional-testwrite tests, the latter against the running application with the HTTP client of the JDK.instructions.src/main/templatesa 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 FILEruns the command of the operating system from the console.less-asset-pipelineand for thesecurityfeature of therest-apiprofile. Both are retired; the upgrade notes name the dependency to declare for each.maven-publishof the plugin profile is the optionalgrails-publishfeature of the plugin types.grails-publishis not a default of the plugin types. A generated plugin has the version0.1, which the publish plugin takes for a release to sign; a plugin author selects the feature.Related
Main-Classof thegrails-clijar, the commands fromhelp --json,run-appas the Gradle taskbootRun)../grailsw list-pluginsgrails-plugins-metadata#128 (a source forlist-plugins) is answered by the commands reading the index.