fix: restore cached Gradle frontend build outputs#24314
Conversation
|
|
|
Thanks for your contribution @benstpierre ! I've started the blocked validation, let's see how gradle tests end up. |
|
|
So anything left for me to do? This case has been insanely aggravating for years. |
|
@benstpierre I'm going to review and test this PR today. I'll keep you posted. |
|
@benstpierre could you please sign the CLA? Otherwise we cannot merge your patch as is, but we need to make a new PR on our own based on this one. |
There was a problem hiding this comment.
Added a first bunch of comments; in the meanwhile I'll make some manual test
- BuildFrontendTokenService still references
build/resources/main/, but since this PR changesservletResourceOutputDirectoryit should most likely mentionbuild/vaadin-build-frontend/.
| val svc = (project.tasks.getByName("vaadinBuildFrontend") | ||
| as VaadinBuildFrontendTask).getTokenService().orNull | ||
| svc?.ensureToken() | ||
| if (task.isVaadinApplicationArchiveTask()) { |
There was a problem hiding this comment.
Why is this condition needed? Is this to avoid the configuration for sources and Javadoc JARs?
Wouldn't this check potentially break projects that define custom-named JAR tasks or using shadow/fatJAR plugins?
| "Skipping task ':vaadinBuildFrontend' as it is up-to-date") } | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
We should probably add a test for a plain JAR, since the plugin code allows it.
|
I set up a repository as an attempt to have some tests for the Gradle build cache. I hope this correctly covers the usage of build cache. Here are two builds:
I plan to add a scenario also for the custom |



Summary
Fixes #24012.
vaadinBuildFrontendpreviously wrote production servlet resources intobuild/resources/<sourceSet>/META-INF/VAADIN, which overlaps with Gradle'sprocessResourcesoutput. That makes the task's production bundle hard to restore safely from Gradle's build cache: a cache hit can restore the task marker/token while leaving the archive withoutMETA-INF/VAADIN/webappassets.This change moves the default
frontendOutputDirectoryfor Gradle production builds to a dedicated task-owned directory:and declares the corresponding servlet resource directory as an
@OutputDirectoryofvaadinBuildFrontend.Packaging tasks now explicitly consume that task-owned output directory:
Jar: packaged at archive rootWar: packaged underWEB-INF/classesBootJar: packaged underBOOT-INF/classesThis keeps the archive layout unchanged while allowing Gradle to restore the production frontend bundle from the build cache.
Tests
Run from
flow-plugins/flow-gradle-pluginwith Java 21:The new regression test verifies that after deleting the local production frontend output, cached token, and WAR, the next
--build-cache -Pvaadin.productionMode buildrestores:vaadinBuildFrontend FROM-CACHEand the rebuilt WAR still contains the Vaadin production bundle.