flow: Cannot benefit from Gradle configuration cache due to cache problems
Description of the bug
With new Gradle 8.6 and the latest setup-gradle@v3 it is now possible to safely and securely store Gradle configuration cache which should improve the Gradle daemon startup and build times.
Unfortunately when using the Vaadin Gradle Plugin the configuration cache fails with the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache problems found in this build.
15 problems were found storing the configuration cache, 13 of which seem unique.
- Class `com.vaadin.flow.server.frontend.FrontendToolsLocator`: external process started '/opt/hostedtoolcache/node/18.19.0/x64/bin/node -v'
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.vaadin.flow.server.frontend.FrontendToolsLocator`: external process started 'which node'
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.vaadin.flow.server.frontend.FrontendUtils`: external process started '/opt/hostedtoolcache/node/18.19.0/x64/bin/node --version'
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `gradlegitproperties.org.eclipse.jgit.util.FS`: external process started '/usr/bin/git --version'
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `gradlegitproperties.org.eclipse.jgit.util.FS`: external process started '/usr/bin/git config --system --edit'
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Task `:data:generateJooqSources` of type `org.gradle.api.tasks.JavaExec`: cannot serialize object of type 'org.gradle.api.internal.tasks.DefaultSourceSet', a subtype of 'org.gradle.api.tasks.SourceSet', as these are not supported with the configuration cache.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:webapp:copyClasspathResourcesForDockerImage` of type `org.gradle.api.DefaultTask`: cannot serialize Gradle script object references as these are not supported with the configuration cache.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:webapp:copyClasspathResourcesForDockerImage` of type `org.gradle.api.DefaultTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:webapp:generateGitProperties` of type `com.gorylenko.GenerateGitPropertiesTask`: invocation of 'Task.project' at execution time is unsupported.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
- Task `:webapp:vaadinBuildFrontend` of type `com.vaadin.gradle.VaadinBuildFrontendTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:webapp:vaadinBuildFrontend` of type `com.vaadin.gradle.VaadinBuildFrontendTask`: invocation of 'Task.project' at execution time is unsupported.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
- Task `:webapp:vaadinPrepareFrontend` of type `com.vaadin.gradle.VaadinPrepareFrontendTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:webapp:vaadinPrepareFrontend` of type `com.vaadin.gradle.VaadinPrepareFrontendTask`: invocation of 'Task.project' at execution time is unsupported.
See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
See the complete report at file:///home/runner/work/project/build/reports/configuration-cache/1jq3mq1vr8s4v3i6l9aeumbf8/96wlf1meeyl5jhjnfvpm1p2sy/configuration-cache-report.html
> Starting an external process '/usr/bin/git --version' during configuration time is unsupported.
> Starting an external process '/usr/bin/git config --system --edit' during configuration time is unsupported.
> Starting an external process 'which node' during configuration time is unsupported.
> Starting an external process '/opt/hostedtoolcache/node/18.19.0/x64/bin/node -v' during configuration time is unsupported.
> Starting an external process '/opt/hostedtoolcache/node/18.19.0/x64/bin/node --version' during configuration time is unsupported.
The full error log with stacktrace can be found in the attached file:
Expected behavior
Gradle build should pass successfully with configuration cache enabled.
Minimal reproducible example
- Add this to your
projectRoot/gradle.properties:
# Kotlin
kotlin.caching.enabled=true
kotlin.incremental=true
kotlin.incremental.useClasspathSnapshot=true
kotlin.parallel.tasks.in.project=true
# Gradle
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon.idletimeout=3600000
org.gradle.configuration-cache=true
org.gradle.configuration-cache.max-problems=100
- Generate a “secret phrase” using
openssl rand -base64 16and store it as a secretGRADLE_ENCRYPTION_KEY - In your workflow add the following:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
# The Gradle wrapper's version (already the default, putting it here to clarity)
gradle-version: wrapper
# Removing unused files from Gradle User Home before saving to cache (i.e. older versions of gradle)
gradle-home-cache-cleanup: true
# Cache downloaded JDKs in addition to the default directories.
gradle-home-cache-includes: |
caches
notifications
jdks
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
# Only write to the cache for builds on the 'main' and 'release' branches. (Default is 'main' only.)
# Builds on other branches will only read existing entries from the cache.
#cache-read-only: ${{ github.ref != 'refs/heads/main' }}
# Allow writing to cache
cache-read-only: true
- name: Build project
env:
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
run: ./gradlew build --scan --stacktrace
Versions
- Vaadin / Flow version: 24.3.3
- Java version: 21-tem
- OS version: ubuntu
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 19
- Comments: 15 (3 by maintainers)
Commits related to this issue
- feat: add support for Gradle configuration cache Fixes #18612 — committed to vaadin/flow by mcollovati 2 years ago
- feat: add support for Gradle configuration cache Part of vaadin/flow#18612 — committed to vaadin/hilla by mcollovati 2 years ago
- feat: add support for Gradle configuration cache ² ✔ ² 10030 ² 17:37:46 Part of vaadin/flow#18612 — committed to vaadin/platform by mcollovati 2 years ago
- feat: add support for Gradle configuration cache Part of vaadin/flow#18612 — committed to vaadin/platform by mcollovati 2 years ago
- feat: add support for Gradle configuration cache Part of vaadin/flow#18612 — committed to vaadin/hilla by mcollovati 2 years ago
- feat: add support for Gradle configuration cache Part of vaadin/flow#18612 — committed to vaadin/platform by mcollovati 2 years ago
- feat: add support for Gradle configuration cache (#21022) Fixes #18612 — committed to vaadin/flow by mcollovati 2 years ago
- feat: add support for Gradle configuration cache (#3288) * feat: add support for Gradle configuration cache Part of vaadin/flow#18612 Co-authored-by: Vaadin Bot <vaadin-bot@users.noreply.github.com... — committed to vaadin/hilla by mcollovati 2 years ago
- chore: bump versions to 24.8 (#3286) * chore: bump versions to 24.8 * feat: add support for Gradle configuration cache (#3288) * feat: add support for Gradle configuration cache Part of vaadin/flo... — committed to vaadin/hilla by platosha 2 years ago
- feat: add support for Gradle configuration cache (#7376) Part of vaadin/flow#18612 — committed to vaadin/platform by mcollovati 2 years ago
- chore: bump vaadin 24.8-SNAPSHOT (#7375) * chore: bump vaadin 24.8-SNAPSHOT * feat: add support for Gradle configuration cache (#7376) Part of vaadin/flow#18612 * use hilla 24.8-SNAPSHOT * Update... — committed to vaadin/platform by ZheSun88 2 years ago
Gradle 8.11 came out today with further improvements to configuration cache performance. Sadly we cannot take advantage of it due to this bug. https://docs.gradle.org/8.11/release-notes.html
Gradle’s configuration cache seems to be a new feature in latest versions and, thus, I’d consider this as an enhancement in Vaadin, despite current Gradle plugin fails with it. Let us read about this feature in Gradle and figure out how we can fix the above errors.
After one week of use, seems to be working.
@mshabarov Apologies for replying so late. We had a lot of things going on and we only now were able to check this out. We can also confirm we’re seeing positive performance improvements. Our local builds are running about a minute faster if the config cache is hit which is a win. There was a slightly less performance benefit in GH Actions, but that’s probably something else.
Thanks for fixing this one! 😃
@steve-todorov and all who interested in Gradle configuration cache support, could you please guys try using Vaadin 24.8.0.alpha1 pre-release that has this support and let us know about the result?