matrei commented on issue #16347:
URL: https://github.com/apache/grails-core/issues/16347#issuecomment-5726855860

   Thanks for the report and the minimal reproduction, @tprebs. I could 
reproduce it with your project and found the cause.
   
   ### What happens
   
   `GrailsGradlePlugin.configureAssetCompilation()` is compiled dynamically 
(`@CompileDynamic`) and calls a private method of the same class, 
`configureAssetsOnTheClasspath()`.
   
   It is not the compilation that leaves the daemon in a bad state, but the 
`buildProperties` task, which `classes` depends on in an application module:
   
   ```bash
   ./gradlew --stop
   ./gradlew :web-module:compileGroovy && ./gradlew projects     # succeeds
   ./gradlew --stop
   ./gradlew :web-module:buildProperties && ./gradlew projects   # fails
   ```
   
   Once that task has executed, Gradle has replaced the meta class of the 
applied plugin class. Printing it from `build.gradle` in two consecutive builds 
on the same daemon shows:
   
   ```
   1st build: GrailsWebGradlePlugin -> groovy.lang.MetaClassImpl
   2nd build: GrailsWebGradlePlugin -> 
org.gradle.internal.classpath.CallInterceptingMetaClass
   ```
   
   Under the Groovy 3.0.24 runtime of Gradle 8.14.3, a dynamic call made 
through that meta class no longer finds a private method declared in the 
superclass when the receiver is a `GrailsWebGradlePlugin`, hence the 
`MissingMethodException`. The daemon keeps the plugin classes loaded between 
builds, so every later build fails while applying the plugin, regardless of 
which task was requested. `grails-plugin` modules are not affected because 
`GrailsPluginGradlePlugin` registers its own `buildProperties` task.
   
   ### Workaround
   
   Update the Gradle wrapper to Gradle 9:
   
   ```bash
   ./gradlew wrapper --gradle-version 9.7.1
   ```
   
   With your project and 8.0.0-M6 on Gradle 9.7.1 (Groovy 4.0.32), the meta 
class is replaced in exactly the same way, but the call resolves and the second 
build succeeds.
   
   Note that this is where Grails 8 is heading anyway: the current `8.0.x` 
branch uses `GroovyCompileOptions.getConfigurationScriptFile()`, which only 
exists from Gradle 9.7, so with the current snapshot a Gradle 8.14.3 build 
fails on the first `compileGroovy` with a `NoSuchMethodError`. That requirement 
is not stated in the upgrade guide yet, which we should fix as well.
   
   ### Fix
   
   Independent of the Gradle version, the plugin should not dispatch to one of 
its own private methods dynamically. Moving the asset pipeline extension access 
(the only part that needs dynamic dispatch) into its own method, so that 
`configureAssetCompilation()` is statically compiled, resolves it. I verified 
that change against your reproduction on Gradle 8.14.3: the meta class is still 
replaced, and `buildProperties` followed by `projects` now succeeds on the same 
daemon. I did not find any other private method called from dynamically 
compiled code in the plugins.
   
   Fixed by #16352 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to