realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Add support for Gradle Configuration Cache #7750

Closed pstavytskyi-turo closed 1 year ago

pstavytskyi-turo commented 1 year ago

Description

This PR fixes Gradle Configuration Cache support of Realm Gradle Plugin. Related to this issue: https://github.com/realm/realm-java/issues/7299

Problem

Currently, the -transform-api versions of Realm do not support Gradle Configuration Cache. The reason is that ModifyClassesTask class in Realm Gradle Plugin uses a reference to Project object which is something that is now allowed by Config Cache. The build fails with the error below:

4 problems were found storing the configuration cache.
- Task `:app:debugRealmAccessorsTransformer` of type `io.realm.transformer.ModifyClassesTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
...

Solution

The solution is to move all of the usages of Project object out of the Gradle task at the registration step. This way, Configuration cache works as expected. Tested with AGP 8.0

cla-bot[bot] commented 1 year ago

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Pavlo Stavytskyi. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails
cla-bot[bot] commented 1 year ago

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Pavlo Stavytskyi. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails
cla-bot[bot] commented 1 year ago

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Pavlo Stavytskyi. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails
pstavytskyi-turo commented 1 year ago

Hey @rorbech , @cmelchior could you please take a look at this PR? Thanks!

rorbech commented 1 year ago

Hi @pstavytskyi-turo. Thanks for the contribution. I have replaced this PR with #7753 to get CI validation of the PR.