fix(auto-install): Pass install state via rule params (GRADLE-112)#1352
Open
runningcode wants to merge 1 commit into
Open
fix(auto-install): Pass install state via rule params (GRADLE-112)#1352runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
The auto-install component metadata rules read the resolved Sentry version and enabled flag from AutoInstallState, a process-global mutable singleton. Each project that applied the plugin wrote its own values into that shared instance during configuration, which breaks project isolation and could let one project observe another project's auto-install version. Resolve the version and enabled flag inside the implementation configuration's withDependencies hook and pass them to each rule as ComponentMetadataRule params, so the rules no longer depend on shared mutable state. Delete AutoInstallState and the per-build cleanup task the singleton required. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
387d415 to
6d505df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GRADLE-112.
Problem
The auto-install
ComponentMetadataRules (AbstractInstallStrategy,WarnOnOverrideStrategy) read the resolved Sentry version and theenabledflag fromAutoInstallState— a process-global mutable singleton. Each project that applied the plugin wrote its own values into that shared instance during configuration:Mutating build-wide shared state from per-project configuration breaks project isolation, and could let one project's rules observe another project's auto-install version. The singleton also required a
BuildFinishedListenerService-based reset and a per-buildcleanupAutoInstallStatetask in tests to avoid leaking across builds in the Gradle daemon.Fix
Resolve the
enabledflag and Sentry version inside theimplementationconfiguration'swithDependencieshook (where they're already computed) and pass them to each rule asComponentMetadataRuleparams(...). The rules now read the two values from their constructor instead of a global, so there's no shared mutable state across projects.AbstractInstallStrategy/WarnOnOverrideStrategytakeautoInstallEnabled+sentryVersionvia constructor.InstallStrategyRegistrar.register(...)forwards them intowithModule { params(...) }.AutoInstallStateand thecleanupAutoInstallStatetest task are deleted.Testing
./gradlew -p plugin-build test --tests "io.sentry.android.gradle.autoinstall.*"— all auto-install unit tests pass../gradlew -p plugin-build integrationTest --tests "io.sentry.android.gradle.integration.SentryPluginAutoInstallNonAndroidTest"— full non-Android auto-install integration suite passes, exercising thewithDependencies+params()wiring end-to-end (including the delayed Spring strategies, the disabled case, and version-override behavior). The Android variant uses the identical code path and runs in CI.