Gradle configuration cache works on local machine but fails on GitHub Actions

2k Views Asked by At

In gradle.properties I'm setting

org.gradle.unsafe.configuration-cache=true

This works without errors on my local machine. The output is:

0 problems were found storing the configuration cache.

When I set up a job on GitHub Actions, it only succeeds if I deactivate the configuration cache. When it is activated I get this log:

3 problems were found storing the configuration cache, 1 of which seems unique.
- Task `:app:buildKotlinToolingMetadata` of type `org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask$FromKotlinExtension`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/7.4.2/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

See the complete report at file:///home/runner/work/***/***/build/reports/configuration-cache/3lar58wlvtv9703t0m3olblg9/gwoz69d8l961obatzzelsv4d/configuration-cache-report.html

> Invocation of 'Task.project' by task ':app:buildKotlinToolingMetadata' at execution time is unsupported.

My primary interest is why this behaves differently.

I'm also wondering what the best workaround is. (Can tasks be skipped from caching? Or how would you deactivate the configuration cache on the CI server?)

2

There are 2 best solutions below

0
Peter F On

I haven't understood the cause yet.

My current workaround is to disable the configuration cache on CI builds adding the option --no-configuration-cache to all gradle commands e.g.

./gradlew test --no-configuration-cache

This overwrites the setting of gradle.properties.

0
Arlak On

Same here, config cache is failing in jenkins pipeline, and working fine in local.

See this comment, it helped. It changes the error to a warning, lets it ignore problems in the config cache (only when it fails) and stores it anyway

Console Output:

3 problems were found storing the configuration cache, 1 of which seems unique.
- Task `:app:buildKotlinToolingMetadata` of type `org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask$FromKotlinExtension`: invocation of 'Task.project' at execution time is unsupported.
....
...

BUILD SUCCESSFUL in 4m 56s
1779 actionable tasks: 715 executed, 1062 from cache, 2 up-to-date
Configuration cache entry stored with 3 problems.

I will update about it's impact if there is any.