Use a BuildService to always collect project root

Using `settingsEvaluated` meant that the project root was not recorded
when the build was run with a config-cache hit. This meant that the subsequent
build would not restore the config-cache, resulting in a cache miss.

In order to avoid issues running the init script on older versions of Gradle
the project-collection is extracted into a separate groovy file that is only
applied conditionally on Gradle 7 or higher.
This commit is contained in:
Daz DeBoer 2022-06-03 10:45:51 -06:00
parent cde0632795
commit ae74c01440
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
4 changed files with 58 additions and 12 deletions

View file

@ -195,7 +195,7 @@ By default, this action aims to cache any and all reusable state that may be spe
The state that is cached includes:
- Any distributions downloaded to satisfy a `gradle-version` parameter ;
- A subset of the Gradle User Home directory, including downloaded dependencies, wrapper distributions, and the local build cache ;
- Any [configuration-cache](https://docs.gradle.org/nightly/userguide/configuration_cache.html) data stored in the project `.gradle` directory.
- Any [configuration-cache](https://docs.gradle.org/nightly/userguide/configuration_cache.html) data stored in the project `.gradle` directory. (Only supported for Gradle 7 or higher.)
To reduce the space required for caching, this action makes a best effort to reduce duplication in cache entries.