codeconsole opened a new pull request, #16702:
URL: https://github.com/apache/grails-core/pull/16702
## Description
`compileGroovyPages` and `compileWebappGroovyPages` were made uncacheable in
fe4c9cfc2e (#16094). The reason given was that the key described neither the
Groovy nor the Java that compiled the pages. Both are in the key:
- `AbstractCompile` declares `getClasspath()` a `@Classpath` input. The
forked compiler runs from that classpath, so the Groovy that compiles the pages
is fingerprinted by its contents.
- `javaLauncher` is `@Nested` (f813b48af6), and `targetCompatibility` is an
`@Input`.
With caching turned on, `-Dorg.gradle.caching.debug=true` lists them:
```
Appending input value fingerprint for
'javaLauncher.metadata.languageVersion' to build cache key: ...
Appending input value fingerprint for 'targetCompatibility' to build cache
key: ...
Appending input file fingerprints for 'classpath' to build cache key: ... -
CLASSPATH{...}
Appending input file fingerprints for 'source' to build cache key: ... -
RELATIVE_PATH{...}
```
Because this task is uncacheable, every fresh checkout, worktree and CI run
forks a compiler for each project with views, even when nothing it reads has
changed. This PR restores `@CacheableTask` and rewrites the javadoc to say what
the key holds.
## Tests
New `GroovyPageBuildCacheFunctionalSpec` (TestKit, with the existing
stand-in compiler):
- Pages compiled in one checkout are restored (`FROM-CACHE`) in a copy of it
in another directory.
- When the classpath carries another Groovy, the pages are compiled again.
Switching back restores the first entry.
- When the target compatibility changes, the pages are compiled again.
- The task is `@CacheableTask`, and `getClasspath()` carries `@Classpath`.
I also checked that the tests catch a regression. Putting
`@DisableCachingByDefault` back fails three of the four tests. Making the
classpath `@Internal` fails the Groovy test and the annotation test.
All of `org.grails.gradle.plugin.views.gsp.*` passes (48 tests), as does
`:grails-gradle-plugins:codeStyle`.
## Effect
I measured an application with 17 projects that have views, using `./gradlew
compileGroovyPages --build-cache` into a fresh build directory each time, with
the rest of the build already in the cache:
| | wall time | page compiles |
|---|---|---|
| uncached (8.0.0) | 78 s | 17 executed |
| cached (this change) | 13 s | 17 from cache |
--
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]