Skip to content

Cannot benefit from Gradle configuration cache due to cache problems #18612

@steve-todorov

Description

@steve-todorov

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:

error.log

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 16 and store it as a secret GRADLE_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

Sub-issues

Metadata

Metadata

Assignees

Projects

Status

June 2025 (24.8)

Status

Done

Status

Done / Pending Release

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions