Skip to content

Fix Groovy compilation on Gradle 9.7 and upgrade to 9.7.1 - #16114

Merged
codeconsole merged 23 commits into
apache:8.0.xfrom
codeconsole:fix/gradle-97-groovy-config-script
Sep 2, 2026
Merged

codeconsole merged 23 commits into
apache:8.0.xfrom
codeconsole:fix/gradle-97-groovy-config-script

Conversation

@codeconsole

@codeconsole codeconsole commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

GrailsGradlePlugin assigned groovyOptions.configurationScript from a doFirst. Gradle finalizes task properties before any task action runs, so from Gradle 9.7 — where GroovyCompileOptions became a lazy property — every Groovy compilation in every Grails project fails:

> The value for task ':compileGroovy' property 'groovyOptions.configurationScriptFile' is final and cannot be changed any further.

There is no user-side workaround and no Gradle opt-out flag.

Fix

A GrailsCompilerConfigScriptTask produces the combined script, and the compile task depends on it. The script is built from grails { } state and reads no classpath, so the task takes the Grails half as one @Input string and the build's own configurationScript, when there is one, as an @InputFile: up-to-date checked, validated by Gradle when that file is missing, and it stores and reuses a configuration cache entry. Every GroovyCompile is covered — the source-set ones get a generator up front, and one a build registers directly gets it when its dependencies are resolved.

GrailsGroovyCompilerConfigSpec covers the lifecycle: a GroovyCompile registered after the project is evaluated, one no source set owns, a configurationScript the build assigns from any configuration callback, one produced by another task, one that does not exist, a generator per source set, and a plugin's version and name staying inputs of its compile task.

Behaviour changes

Both are in the star imports, which stay opt-in — importGrailsCommonAnnotations and starImports default to off.

  • importGrailsCommonAnnotations now adds grails.gorm.annotation and grails.plugin.scaffolding.annotation without first probing the compile classpath. A star import of a package that is not on the classpath contributes no classes and is not an error in Groovy.
  • importJavaTime is removed. Groovy 5 imports java.time by default, so it did nothing on Grails 8. A build that sets it fails with Could not set unknown property 'importJavaTime'; drop the line.

Both are documented in the Grails 8 upgrade guide, section 53.

Gradle 9.7.1

Grails builds on 9.7.1: .sdkmanrc, gradleToolingApiVersion, and the wrapper for root, build-logic, grails-gradle, grails-forge, end-to-end, plus the grails-shell-cli gradle-sample fixture. end-to-end/legacy-g7-command-plugin stays on Gradle 8.14.5, the version Grails 7 pins for that fixture.

Applications created by the forge and the profile CLIs get a 9.7.1 wrapper as well. They can only move to 9.7 together with the fix above; without it the first compileGroovy fails.

`configureGroovyCompiler` assigned `groovyOptions.configurationScript` from a
`doFirst` on each GroovyCompile task. Gradle finalizes task properties before
any task action runs, so from Gradle 9.7 — where GroovyCompileOptions became a
lazy property — every Groovy compilation fails:

    Execution failed for task ':compileGroovy'.
    > The value for task ':compileGroovy' property
      'groovyOptions.configurationScriptFile' is final and cannot be changed
      any further.

Assigning the property during configuration is not enough on its own: Gradle
then treats the script as an input file that must exist before the compile task
runs, which fails on a clean build because `doFirst` runs after input
validation. So the combined script is now produced by a dedicated task that the
compile task depends on.

That task is marked `doNotTrackState`, which keeps the property that motivated
the original `doFirst`: generating the script needs the resolved compile
classpath, and declaring it as an input would pull the runtimeClasspath into the
task's up-to-date check. The script is cheap to build, so it is simply
regenerated on every build.

Wiring moves to `afterEvaluate` so a `configurationScript` set by the build
script is already in place and gets folded into the combined script rather than
clobbered — the merge the old execution-time read performed. Task names are read
via `TaskCollection.names`, which does not realize the tasks.

Verified against a multi-project Grails 8 application on both Gradle 9.6.1 and
9.7.0: full `bootJar`, and `clean` plus compilation in a single invocation.
@codecov

codecov Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.11111% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.7201%. Comparing base (f3a91d3) to head (5684ed1).
⚠️ Report is 18 commits behind head on 8.0.x.

Files with missing lines Patch % Lines
...rails/gradle/plugin/core/GrailsGradlePlugin.groovy 0.0000% 39 Missing ⚠️
...compiler/beans/AutoConfigurationImportsWriter.java 84.3374% 3 Missing and 10 partials ⚠️
.../plugin/core/GrailsCompilerConfigScriptTask.groovy 0.0000% 6 Missing ⚠️
...s/compiler/beans/GrailsBeansASTTransformation.java 75.0000% 0 Missing and 4 partials ⚠️
...ion/GlobalGrailsClassInjectorTransformation.groovy 80.0000% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #16114        +/-   ##
==================================================
+ Coverage     54.7109%   54.7201%   +0.0092%     
- Complexity      20420      20465        +45     
==================================================
  Files            2101       2104         +3     
  Lines          100978     101089       +111     
  Branches        17907      17925        +18     
==================================================
+ Hits            55246      55316        +70     
- Misses          37863      37896        +33     
- Partials         7869       7877         +8     
Files with missing lines Coverage Δ
...orm/mongodb/embedded/EmbeddedMongoInitializer.java 95.9016% <100.0000%> (ø)
...n/core/AutoConfigurationImportsCompileInput.groovy 100.0000% <100.0000%> (ø)
...g/grails/gradle/plugin/core/GrailsExtension.groovy 55.3571% <ø> (ø)
...ion/GlobalGrailsClassInjectorTransformation.groovy 84.4538% <80.0000%> (+0.4202%) ⬆️
...s/compiler/beans/GrailsBeansASTTransformation.java 85.9813% <75.0000%> (-0.2746%) ⬇️
.../plugin/core/GrailsCompilerConfigScriptTask.groovy 0.0000% <0.0000%> (ø)
...compiler/beans/AutoConfigurationImportsWriter.java 84.3374% <84.3374%> (ø)
...rails/gradle/plugin/core/GrailsGradlePlugin.groovy 0.0000% <0.0000%> (ø)

... and 3 files with indirect coverage changes

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

@codeconsole codeconsole changed the title Generate the Groovy compiler config script in its own task (fixes Gradle 9.7) Gradle 9.7.0 Upgrade - Generate the Groovy compiler config script in its own task (fixes Gradle 9.7) Aug 7, 2026
Moves grails-core's own build onto 9.7.0: `.sdkmanrc`, `gradleToolingApiVersion`,
and the wrapper for every Gradle build in the repository — root, build-logic,
grails-gradle, grails-forge, end-to-end — plus the grails-shell-cli gradle-sample
fixture.

The shared wrappers were regenerated with `gradle -p gradle-bootstrap`; the
gradle-sample fixture, which bootstrap does not reach, was refreshed from the
same output so the launcher scripts and wrapper jar stay byte-identical
everywhere.

`end-to-end/legacy-g7-command-plugin` deliberately stays on Gradle 8.14.5, the
version Grails 7 pins for that fixture.

The wrapper task regenerates the properties files from scratch, so the
"keep this synced" checklist comments were restored afterwards.
Applications created by the forge and by the profile CLIs now get a 9.7.0
wrapper instead of 9.6.0.

For the forge, that means the `gradleWrapperProperties` template plus the three
binaries `Gradle.java` copies onto the generated project — `gradlew`,
`gradlew.bat`, and `gradle/wrapper/gradle-wrapper.jar`.

For the profile CLIs, only the `base` and `profile` skeletons carry wrapper
assets; `web`, `rest-api`, and `plugin` inherit them from `base` through
`profileRuntimeApi`, and `web-plugin` / `rest-api-plugin` chain through those,
so every application type picks the new wrapper up.

Generated applications can only move to 9.7 together with the compiler config
script fix earlier in this branch — without it every Groovy compilation in a
Grails project fails on Gradle 9.7.
@codeconsole
codeconsole requested review from borinquenkid, jamesfredley, jdaugherty, matrei and sbglasius and removed request for jdaugherty and matrei August 7, 2026 21:41

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reproduced three lifecycle failures against this exact head. Inline comments include the commands/observable failures and focus only on correctness gaps.

// Wiring happens after evaluation so a configurationScript set by the build script is already
// in place and gets folded into the combined file rather than clobbered. Names are read via
// TaskCollection.names, which does not realize the tasks.
project.afterEvaluate {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one-time snapshot regresses the previous live configureEach behavior. A GroovyCompile registered from a later projectsEvaluated callback is absent from names and receives no generator/configuration script; I reproduced this against this head (LATE_GROOVY_UNCONFIGURED=true, with no generateLateGroovyGrailsCompilerConfig task). Please retain live wiring without registering a generator from inside the task-container callback (for example, a deferred task rule plus string dependsOn) and add a late-task TestKit case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 8b8d063. TaskCollection.names is an immutable snapshot, so a GroovyCompile registered after the afterEvaluate got no generator and no configuration script, silently.

Generator tasks are now registered from sourceSets.configureEach, which is live — source sets are what create GroovyCompile tasks, so a source set added from projectsEvaluated is covered.

One correction on the suggested remedy: a task rule plus string dependsOn does not work. Rules are not consulted when resolving a dependsOn name — the build fails at graph construction with Task with name 'generateCompileGroovyGrailsCompilerConfig' not found. And registering the generator from inside the task-container callback is what the snapshot was avoiding in the first place: it throws TaskCreationException: Could not create task ':compileGroovy'. Hooking the source-set container sidesteps both.

Test: GrailsGroovyCompilerConfigSpec — a GroovyCompile registered after the project is evaluated still gets a generator.

// the inputs to this task would effectively be the runtimeClasspath, dependency
// problems can arise if another task changes the runtimeClasspath. Generating the
// script is cheap, so skip state tracking and regenerate on every build instead.
t.doNotTrackState('Depends on the resolved compile classpath; cheap to regenerate')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

doNotTrackState suppresses validation but does not establish execution ordering. The doLast calls getGroovyCompilerScript, which scans compileTask.classpath, while this generator has no dependency on tasks producing those classpath entries. I forced a classpath producer to run after the generator on a clean build; the generator omitted grails.gorm.annotation, then compileGroovy failed with unable to resolve class CreatedDate. Please model the classpath/base script as inputs and depend on their producer tasks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right that doNotTrackState establishes no ordering — the generator declared no dependencies at all while its action resolves compileTask.classpath and reads jar entries from it. Fixed in 8b8d063: it now depends on the classpath's own build dependencies.

I used dependsOn rather than declaring the classpath as an input, because modelling it as an input reintroduces exactly what doNotTrackState is there to prevent — it drags the runtimeClasspath into the up-to-date check. dependsOn gets the ordering without the tracking.

For the record on severity: I could reproduce the missing edge, but not the failure. In the natural task graph Gradle schedules the producing jar before the generator, and the two probed classes normally come from external jars already in the module cache. That matches your note that you had to force the ordering. Still worth closing — it was a real latent hazard.

Test: GrailsGroovyCompilerConfigSpec — the generator runs after the tasks that produce the compile classpath.

combinedFile.write(combinedScripts)
c.groovyOptions.configurationScript = combinedFile
compileTask.configure { GroovyCompile c ->
userConfigurationScript[0] = c.groovyOptions.configurationScript

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This capture/replace is not stable for later configuration. When a user assigns configurationScript from a later projectsEvaluated callback, that assignment overwrites the combined script after this action. Reproduced result: the user's LocalDate import worked, but the generated Grails CreatedDate import disappeared and compilation failed. Please capture the final configured script at a graph-safe point (or wire it provider-first) and cover a later-callback assignment in TestKit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 8b8d063. Capturing during afterEvaluate meant an assignment from any later callback simply overwrote the combined file and the Grails imports disappeared with no error.

Capture and assignment now happen at taskGraph.whenReady — the last point before execution and after every configuration callback has run, so the user's final value is what gets folded in. The property is still assignable there on 9.7.

Scope note for anyone reading later: the ordinary path — assigning configurationScript directly in the build script — was already merging correctly. Only assignment from a later callback was affected.

Test: GrailsGroovyCompilerConfigSpec — a configurationScript assigned from a later callback is folded in, not clobbered.

Moving the compiler configuration script off a `doFirst` traded three
execution-time guarantees for configuration-time snapshots. Each one is restored:

Late-registered compile tasks are wired again. `TaskCollection.names` read inside
`afterEvaluate` is an immutable snapshot, so a `GroovyCompile` created later — by a
source set added from `projectsEvaluated`, or from another plugin's `afterEvaluate` —
got no generator and no configuration script, silently. Generator tasks are now
registered from `sourceSets.configureEach`, which is live. They cannot be registered
from a `GroovyCompile` configuration action: mutating the task container while it is
being configured throws `TaskCreationException`, which is what the snapshot was
working around.

The generator is ordered against the compile classpath it reads. `doNotTrackState`
suppresses up-to-date checking but establishes no ordering, and the generator
declared no dependencies at all while its action resolves `compileTask.classpath`
and reads jar entries from it. It now depends on the classpath's own build
dependencies, so the probes see the artifacts. `dependsOn` rather than an input
declaration, to keep the runtimeClasspath out of the up-to-date check — the property
`doNotTrackState` was added to protect.

A `configurationScript` assigned after wiring is folded in rather than dropped. The
user's script was captured during `afterEvaluate`, so an assignment from any later
callback simply overwrote the combined file and the Grails imports disappeared with
no error. Capture and assignment now happen once the task graph is ready, the last
point before execution, after every configuration callback has run.

The capture map is a per-project instance field, not static, so a script cannot leak
into a later build in the same daemon.
@codeconsole

Copy link
Copy Markdown
Contributor Author

Thanks — all three were real. Fixed in 8b8d063 with a regression test each in GrailsGroovyCompilerConfigSpec; each fails against the previous commit.

Common root cause: the fix had to move from execution-time reads to configuration-time snapshots, because Gradle 9.7 forbids assigning groovyOptions.configurationScript from doFirst. The snapshots were narrower than the doFirst they replaced. The wiring is now live (sourceSets.configureEach), ordered against the classpath it reads, and captures the user's script at taskGraph.whenReady instead of during afterEvaluate.

:grails-gradle:test, codeStyle, and a full root build -PskipTests are green on 9.7.0.

@codeconsole codeconsole changed the title Gradle 9.7.0 Upgrade - Generate the Groovy compiler config script in its own task (fixes Gradle 9.7) Fix Groovy compilation on Gradle 9.7 and upgrade to 9.7.0 Aug 8, 2026
@codeconsole codeconsole added this to the grails:8.0.0-RC1 milestone Aug 13, 2026
@jdaugherty

Copy link
Copy Markdown
Contributor

@codeconsole Looking back the code history: we used a separate task previously and the commit message where we reverted this was:

        fix: rework the configuration for the compileGroovy task to prevent task dependency errors if the runtimeclasspath is changed

How does this change then solve this?

@jdaugherty

Copy link
Copy Markdown
Contributor

Do we know why the compile configuration can no longer be changed at execution? This seems like an artificial limitation by Gradle and I'm wondering if we should instead open a bug ticket on this.

…scope

`GroovyCompileOptions.getConfigurationScript()` is annotated
`@ReplacedBy("configurationScriptFile")`: the `File` accessor is superseded by a
`RegularFileProperty`. Assign through that property instead. The eager setter
delegates to it, so a script a build assigns either way is still picked up.

The ordering test now also asserts what the generator must *not* be coupled to. An
earlier task-based design declared `configurations.runtimeClasspath` as a task input,
which pulled the runtime classpath into the generator's up-to-date check and produced
task dependency errors when it changed (9a529d1). This generator declares no
inputs at all and depends only on the compile classpath's build dependencies, which
`compileGroovy` already depends on, so the runtime classpath enters neither the
dependency chain nor an up-to-date check.
…asspath

`isClassOnClasspath` opened jars on the compile classpath to decide whether to add
the `grails.gorm.annotation` and `grails.plugin.scaffolding.annotation` star
imports. That single probe is what forced every other awkward property of this
wiring: the script could only be built at execution time, which is why it was
computed in a task action, why the task opted out of state tracking, and why it
needed an ordering edge to whatever produced the classpath.

The probe bought nothing. A star import of a package that is not on the classpath
contributes no classes and is not an error in Groovy — verified on 5.0.8 for both
dynamic and static compilation — so the imports are now added unconditionally when
`importGrailsCommonAnnotations` is set, exactly as `jakarta.validation.constraints`
already was.

With the classpath out of the picture:

- The generator takes the finished script as a single input property and writes it.
  It is up-to-date checked and cacheable rather than `doNotTrackState`, and needs no
  dependency on the compile classpath, so no configuration enters its dependency
  chain or its up-to-date check.
- The script is built while the compile task is configured, which restores an input
  declaration lost when it moved into a task action: `GrailsPluginGradlePlugin` bakes
  the project version and name into compiled classes as AST metadata and registers
  them as inputs of the compile task. Since 7950482 that ran too late to take
  effect, so changing a plugin's version left the stamped metadata stale.

Regression tests cover all four properties; each fails against 7950482.
A build may point `configurationScript` at a file another task generates. Taking the
property over meant that producer was no longer ordered against the generator, so on
a clean build the generator read the file before it existed and the build's own
script was silently dropped from the combined output — present only from the second
build onwards, off a stale file.

The generator now depends on that producer. Task graph construction runs before the
property is taken over, so the property still carries whatever the build set, and
with it the producing task. Wrapping it in a FileCollection is what asks Gradle for
the producer: depending on the property directly tries to convert the file itself
into a task, and the collection has to be guarded on `present` because building one
from a property with no value fails while dependencies are being resolved.
The script was written by an ad-hoc task configured with `inputs.property` and
`outputs.file` in the plugin. It is now a `GrailsCompilerConfigScriptTask` with an
`@Input Property<String>` and an `@OutputFile RegularFileProperty`, matching how the
rest of this plugin's tasks are written and making the contract legible from the task
rather than from its registration site.

Behaviour is unchanged; the input property is now named for the task's own property.

Tests added for two properties that were not covered: one generator per source set
with a real up-to-date check (unchanged build is UP-TO-DATE, changed imports are not),
and that the wiring stores and reuses a configuration cache entry.
Bumps the patch release across every location the version-sync rule reaches:
`.sdkmanrc`, `gradleToolingApiVersion`, and all eight main-line
`gradle-wrapper.properties`, including the forge and profile skeletons that
generated applications inherit.

9.7.1 leaves the wrapper jar and the `gradlew` scripts untouched, so this is a
`distributionUrl` change only. `end-to-end/legacy-g7-command-plugin` stays on
Gradle 8.14.5, the version Grails 7 pins for that fixture.

SDKMAN has not indexed 9.7.1 yet, so `sdk env` will report it as unreleased until
it does; the wrappers are unaffected because they fetch the distribution directly.
@codeconsole codeconsole changed the title Fix Groovy compilation on Gradle 9.7 and upgrade to 9.7.0 Fix Groovy compilation on Gradle 9.7 and upgrade to 9.7.1 Aug 20, 2026
@@ -2256,7 +2362,278 @@ resolved unambiguously before can become ambiguous.
Removing the packages from `grails.spring.bean.packages`, or the stray classes from those packages, restores
the previous set of beans.

==== 45. `importJavaTime` Removed
==== 45. GORM API Resolution Moves to a Registry

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where does all these lines come from and why are they related to this PR? Seems odd.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They come from 8.0.x, not this PR. Section 45 arrived in #16066 (2926a0f644), and 46/47 likewise predate this branch — all three sit at this same line on upstream/8.0.x today. The branch picked them up when it was brought up to date.

This PR's net change to the file is 39 added lines — section 48, importJavaTime Removed:

git diff upstream/8.0.x HEAD -- grails-doc/src/en/guide/upgrading/upgrading80x.adoc
 1 file changed, 39 insertions(+)

The Files changed tab shows that one hunk. "Changes since your last review" will include the 8.0.x merge, since the approval predates it.

@codeconsole
codeconsole requested a review from sbglasius August 20, 2026 22:20
@codeconsole
codeconsole dismissed sbglasius’s stale review August 20, 2026 22:20

based on upstream merged changes

@codeconsole

Copy link
Copy Markdown
Contributor Author

gradle/gradle#38930

…vy-config-script

# Conflicts:
#	grails-doc/src/en/guide/upgrading/upgrading80x.adoc

@matrei matrei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review:

Review Findings

The current head 7714cded41 addresses the previously reported lifecycle issues, but the following regressions remain.

[P2] Standalone GroovyCompile tasks lose Grails compiler configuration

File: grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:306-312,335-339

Generator tasks are registered only from SourceSetContainer entries:

sourceSets.configureEach { SourceSet sourceSet ->
    registerGroovyCompilerConfigGenerator(project, sourceSet.getCompileTaskName('groovy'))
}

The plugin still configures every GroovyCompile task at lines 314-327, but a standalone task that is not associated with a source set never gets a corresponding generator. The whenReady callback then skips it because the generated task name is absent.

This regresses the previous behavior, where the doFirst compiler-script wiring was attached to every GroovyCompile task. A manually registered task such as:

tasks.register('compileCustomGroovy', GroovyCompile) {
    source('src/custom/groovy')
    destinationDirectory.set(layout.buildDirectory.dir('classes/custom'))
    classpath = sourceSets.main.compileClasspath
}

will not receive starImports, importGrailsCommonAnnotations, a plugin's compiler metadata, or a user-provided configurationScript merged with the Grails script. This is particularly significant for GrailsPluginGradlePlugin, whose override adds projectVersion, projectName, and isPlugin metadata to the compiler script.

Please preserve compiler-script wiring for standalone GroovyCompile tasks, while avoiding task-container mutation during task configuration. Add a TestKit regression test for a standalone task.

[P2] Missing user compiler scripts are silently ignored

File: grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:391-394

The combined script reads a captured user script only when the file exists:

String configuredScript = userScript?.exists() ? (userScript.text?.trim() ?: null) : null

At lines 345-352, the plugin replaces the original configurationScriptFile with the generated combined file. Therefore, Gradle no longer validates the originally configured user file. If a build configures a nonexistent script:

tasks.named('compileGroovy', GroovyCompile) {
    groovyOptions.configurationScript = file('missing-config.groovy')
}

the generator silently emits only the Grails script and compilation proceeds without the requested compiler configuration. Before this change, the execution-time .text access failed for a missing file, making a typo or deleted file visible to the user.

Please retain the producer-task support while ensuring that an explicitly configured user script which remains unavailable fails the build instead of silently disabling compiler behavior. Add coverage for a missing configured script.

Verification

The following focused checks passed:

  • ./gradlew :grails-gradle-plugins:test --tests 'org.grails.gradle.plugin.core.GrailsGroovyCompilerConfigSpec' --no-daemon
  • ./gradlew :grails-gradle-plugins:test --no-daemon
  • ./gradlew :grails-gradle-plugins:compileGroovy :grails-gradle-plugins:compileTestGroovy --no-daemon

The wrapper audit also confirmed the intended Gradle 9.7.1 mainline locations and the intentional Gradle 8.14.5 legacy fixture split.

Two gaps found in review of the generator wiring.

A GroovyCompile that no source set owns, one a build registers directly,
got no generator, so it compiled without the Grails star imports, a
plugin's AST metadata, and the combined script. The generator is now
created on demand when the compile task's dependencies are resolved,
which happens while the task graph is built and outside any task
configuration action, so the container is mutable there. The source-set
hook stays for the tasks it already covered. The whenReady capture walks
the tasks about to run instead of realizing every GroovyCompile in the
project.

A configurationScript pointing at a file that does not exist was dropped
silently: the compile task's own property had been replaced with the
combined file, so Gradle's validation no longer saw it, and the generator
read nothing. The build's script is now an optional @InputFile of the
generator rather than text folded into the @input string, so Gradle fails
the build naming the missing file before the generator runs.
@codeconsole

codeconsole commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor Author

@matrei

Both confirmed and fixed in 818d22b, each with a regression case in GrailsGroovyCompilerConfigSpec that fails against the previous head.

Standalone GroovyCompile. The generator is now created on demand: the compile task's dependsOn resolves to groovyCompilerConfigGenerator(project, name), which registers the task if no source set already did. That resolution happens while the task graph is built — after configuration, when the task container is mutable again — so it is not a registration from inside a task configuration action, which is what throws. The source-set hook stays, so the usual generators are still listed and a late source set is still covered. The whenReady capture now walks graph.allTasks instead of every GroovyCompile name in the project: only the tasks about to run are taken over, and nothing is realized just to be looked at.

Test: a GroovyCompile that no source set owns is wired like the source set ones — a directly registered compileCustomGroovy with a configurationScript of its own compiles with the combined script, carrying both the Grails imports and its own. The same fixture then runs twice with --configuration-cache, so the on-demand generator is shown to be part of the cached graph.

Missing user script. The build's script is now an @InputFile @Optional of the generator rather than text folded into the @Input string, so Gradle's own validation fails the build before the generator runs:

A problem was found with the configuration of task ':generateCompileGroovyGrailsCompilerConfig' (type 'GrailsCompilerConfigScriptTask').
Input file does not exist
  ... property 'configurationScript' specifies file '.../missing-config.groovy' which doesn't exist

Producer support is unchanged: the ordering edge to the task that writes the script is still declared, and the classpath decoupling assertions still hold (GENERATOR_DECLARED_INPUT_FILES=0 when no script is configured).

Test: a configurationScript that does not exist fails the build instead of being dropped.

@codeconsole
codeconsole requested a review from matrei September 2, 2026 04:27
@testlens-app

testlens-app Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 5684ed1
▶️ Tests: 70621 executed
⚪️ Checks: 89/89 completed


Learn more about TestLens at testlens.app/docs.

@codeconsole
codeconsole merged commit 2550800 into apache:8.0.x Sep 2, 2026
92 checks passed
@jdaugherty

Copy link
Copy Markdown
Contributor

I originally raised a concern on this PR in this comment. From what I can tell, it was never addressed or answered, yet this change was merged. I'm frustrated this was merged.

@jdaugherty

Copy link
Copy Markdown
Contributor

From what I recall of the original problem: Add a secondary task dependency on compileGroovy, by adding an intermediate task, now that task dependency must also depend on compileGroovy. This has caused issues in our builds enough for us to revert to a doFirst { } configure in compileGroovy instead

@codeconsole

Copy link
Copy Markdown
Contributor Author

@jdaugherty I understand the concern about reintroducing task-ordering failures. I should have followed up with you to establish whether the change covered your actual build wiring before this was merged.

My earlier explanation addressed the runtime-classpath dependency in the old implementation: the merged generator no longer reads either classpath. That addresses that particular dependency, but does not settle every ordering case you described.

I have now reproduced a narrower case in an execution-level test: a build that assigns a plain configurationScript file and separately adds its producing task to compileGroovy.dependsOn does not order that producer before Grails prepares the combined script. Requesting script preparation first exposes the missing edge and fails because the file does not yet exist. Wiring configurationScriptFile to the producing task's output provider makes the same task request compile and run successfully, including after the generated script changes.

I'm preparing a follow-up with that regression test and upgrade documentation for the provider wiring. It keeps the generator independent of unrelated compilation prerequisites; copying all of those dependencies could introduce cycles. Returning to the old doFirst assignment would also restore the finalized-property failure on Gradle 9.7.

Could you share the actual task registration and compileGroovy wiring from the affected build, including whether the prerequisite writes the compiler script, changes its contents, or only supplies source/classpath entries? That will let us check your specific case rather than assume the reproduced one is the same.

codeconsole pushed a commit to codeconsole/grails-core that referenced this pull request Sep 9, 2026
…asspath

The task-based wiring that 9a529d1 replaced with a doFirst declared
runtimeClasspath as an input of the generator task, so any task whose
output reached the runtime classpath became a transitive dependency of
compileGroovy. A post-compile step that feeds the runtime classpath, such
as asset-pipeline output or the exploded plugin directory, then closed a
cycle. That is the concern raised on apache#16114.

The generator introduced there takes its script from grails { } state
and declares no classpath input, so that edge no longer exists. This
test recreates the scenario: a task that runs after classes and puts its
output on the runtime classpath via runtimeOnly files(task). It asserts
the generator does not depend on that task, and that compileGroovy and
the producer schedule together without a cycle.
antobinary added a commit to antobinary/bigbluebutton that referenced this pull request Sep 23, 2026
Apache Grails published 8.0.0-RC1 on 2026-09-23. Like M6 before it, the
artifacts are in the ASF staging group only while the release vote runs,
so the TEMP staging-repository entries in build.gradle stay for now and
the comments are retargeted at RC1. Spring Boot stays at 4.1.1 (RC1's BOM
manages the same version); Groovy follows the BOM to 5.1.3 and the
cloud.wondrify asset-pipeline plugin to its 5.2.0-RC1 release, which is
already on Maven Central.

The RC1 Grails Gradle plugin is built against Gradle 9.7
(apache/grails-core#16114): on the 9.6.0 wrapper `gradlew assemble` dies
with NoSuchMethodError on
GroovyCompileOptions.getConfigurationScriptFile() returning a
RegularFileProperty. Move the wrapper to 9.7.1, the current release.

RC1 hands multipart handling to Spring Boot's auto-configuration
(apache/grails-core#16040): the grails.controllers.upload.maxFileSize /
maxRequestSize keys are gone, and an application that still sets them
aborts at startup with a migration message. Move bbb-web's limits to
spring.servlet.multipart.max-file-size / max-request-size with the same
values. Without an explicit setting, Boot's defaults (1 MB per file,
10 MB per request) would silently cap presentation and caption uploads;
BigBlueButton's own per-presentation cap (maxFileSizeUpload, enforced by
ParamsProcessorUtil) is unchanged.

Also in RC1 (apache/grails-core#16149) the _method override moved from a
servlet filter into the dispatcher and is off by default, so the disabled
hiddenHttpMethodFilter registration in resources.groovy is now redundant.
It still compiles and stays inert, so it is left alone here.

Verified with a package build in the grails-8 build image, deployed to a
4.0 dev container: startup in 4.4 s without warnings, checksummed
create/getMeetingInfo/end round-trip, a 5.3 MB presentation upload
through the client (above Boot's default per-file limit), and the api,
learningdashboard, presentation and parameters Playwright suites. Every
remaining failure in those suites reproduces with the same signature on
the pre-upgrade Grails 7.0.12 package (screenshot drift, the @flaky
external-video tests, a test needing maskTagThreshold > 0, and the
predefined breakout groups tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants