Skip to content

fix: stop PrepareTask discarding the Configuration Cache entry - #10

Open
soloturn wants to merge 1 commit into
objectbox:mainfrom
soloturn:fix/configuration-cache-prepare-task
Open

soloturn wants to merge 1 commit into
objectbox:mainfrom
soloturn:fix/configuration-cache-prepare-task

Conversation

@soloturn

@soloturn soloturn commented Sep 19, 2026

Copy link
Copy Markdown

PrepareTask held a ProjectEnv — and with it a live Project — as task
state. Any task holding a Project reference is incompatible with the
Gradle Configuration Cache, and an incompatible task discards the cache
entry for the whole build on every run, not just for itself. So any
project applying this plugin could never benefit from the Configuration
Cache, even though nothing else in the build was incompatible.

Fixes objectbox/objectbox-java#948

Fix

PrepareTask now only holds plain values and Provider/Property
instances set via project.provider { } for values (AGP version,
application id, project dir path) that are only reliable once the
project has finished evaluating. GradleBuildTracker and
ObjectBoxGradlePlugin.createPrepareTask are updated accordingly, and
the now-unused ProjectEnv-based androidAppId() helper is removed.

Testing

Added assembleWithConfigurationCache(): runs assembleDebug twice with
--configuration-cache and asserts the first run stores a clean cache
entry (no "problem was found storing the configuration cache") and the
second run reuses it ("Reusing configuration cache.").

Ran the full :objectbox-gradle-plugin:test suite locally; all failures
are pre-existing and environmental (GitLab-authenticated test repository
not reachable outside ObjectBox's own CI — confirmed unrelated to this
change, same failure mode on main).

PrepareTask held a ProjectEnv - and with it a live Project - as task
state. Any task holding a Project reference is incompatible with the
Gradle Configuration Cache, and an incompatible task discards the
cache entry for the whole build on every run, not just for itself.
So any project applying this plugin could never benefit from the
Configuration Cache, even though nothing else in the build was
incompatible.

Fix: PrepareTask now only holds plain values and Provider/Property
instances set via project.provider { } for values (AGP version,
application id, project dir path) that are only reliable once the
project has finished evaluating. GradleBuildTracker and
ObjectBoxGradlePlugin.createPrepareTask are updated accordingly, and
the now-unused ProjectEnv-based androidAppId() helper is removed.

Adds assembleWithConfigurationCache() regression test: runs
assembleDebug twice with --configuration-cache and asserts the first
run stores a clean cache entry and the second run reuses it.

Fixes objectbox/objectbox-java#948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gradle Configuration Cache support for plugin

1 participant