[Don't review]: Add settings plugin with settings-level extension#1178
[Don't review]: Add settings plugin with settings-level extension#1178runningcode wants to merge 8 commits intomainfrom
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Add settings plugin with settings-level extension ([#1178](https://github.com/getsentry/sentry-android-gradle-plugin/pull/1178))If none of the above apply, you can opt out of this check by adding |
Add `io.sentry.android.gradle.settings` settings plugin that provides
a `SentrySettingsExtension` for configuring shared properties (org,
project, authToken, url, debug, telemetry, includeSourceContext,
autoInstallation) once in settings.gradle.kts. These values flow to
each module's project-level extension as conventions via
ExtraPropertiesExtension, following the pattern from
liutikas.net/2024/10/28/DRY-Gradle-Configuration-Values.html.
The settings plugin also auto-applies `io.sentry.android.gradle` to
library and java-library modules, preparing for future multi-module
features (source context, snapshots).
Project-level `sentry {}` overrides still take precedence. Without the
settings plugin, existing behavior is unchanged.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SentryPluginExtension requires Project in its constructor, which is unavailable during settings evaluation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SentryPluginExtension only needed Project to get ObjectFactory, so inject ObjectFactory directly instead. This lets both the settings and project plugins use the same extension class, eliminating SentrySettingsExtension and the duplicated property declarations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Android library modules now get auto-install dependencies via
SentryPlugin's new withPlugin("com.android.library") block
- Java library modules now get the JVM plugin applied instead of the
Android plugin, giving them source context + auto-install
- SentryJvmPlugin reads settings extension defaults
- Warning is suppressed when plugin is applied via settings plugin
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
793b929 to
39ac566
Compare
| org.convention(settings.org) | ||
| projectName.convention(settings.projectName) | ||
| authToken.convention(settings.authToken) | ||
| url.convention(settings.url) | ||
| debug.convention(settings.debug) | ||
| telemetry.convention(settings.telemetry) | ||
| telemetryDsn.convention(settings.telemetryDsn) | ||
| includeSourceContext.convention(settings.includeSourceContext) | ||
| autoInstallation.enabled.convention(settings.autoInstallation.enabled) | ||
| autoInstallation.sentryVersion.convention(settings.autoInstallation.sentryVersion) | ||
| } |
There was a problem hiding this comment.
Bug: The applySettingsDefaults function only propagates a small subset of properties from the settings plugin, causing most configurations set in settings.gradle.kts to be silently ignored.
Severity: MEDIUM
Suggested Fix
Update the applySettingsDefaults function to propagate all relevant properties from the settings-level SentryPluginExtension to the module-level extensions. This will ensure that configurations set in settings.gradle.kts are correctly applied across all modules.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
plugin-build/src/main/kotlin/io/sentry/android/gradle/extensions/SentryPluginExtension.kt#L225-L236
Potential issue: When using the Sentry settings plugin, most configuration properties
set in `settings.gradle.kts` are silently ignored. The `applySettingsDefaults` function
only propagates a small subset of properties (like `org`, `project`, `authToken`) to
module-level Sentry extensions. Other properties available in the
`SentryPluginExtension` DSL, such as `uploadNativeSymbols`, `autoUploadProguardMapping`,
and `tracingInstrumentation`, have no effect when set at the settings level. This is
because a refactor reused the extension for the settings plugin but did not update the
propagation logic to handle all the newly exposed properties, creating a misleading API.
Library modules don't initialize Sentry themselves and auto-installing dependencies could cause version conflicts with the app module. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The settings plugin now only provides shared configuration. Users apply the appropriate plugin to each module themselves. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d543fa2. Configure here.
| includeSourceContext.convention(settings.includeSourceContext) | ||
| autoInstallation.enabled.convention(settings.autoInstallation.enabled) | ||
| autoInstallation.sentryVersion.convention(settings.autoInstallation.sentryVersion) | ||
| } |
There was a problem hiding this comment.
Settings defaults omit paired autoUploadSourceContext property
Medium Severity
applySettingsDefaults forwards includeSourceContext from settings but not its companion property autoUploadSourceContext (which includeSourceContext's own @see tag references as related). Since the settings DSL exposes autoUploadSourceContext (via the shared SentryPluginExtension class), a user could set includeSourceContext.set(true) and autoUploadSourceContext.set(false) in settings expecting source context to be generated but not uploaded. The first setting would propagate correctly, but the second would be silently ignored — every module would still auto-upload with the default true, potentially causing unintended uploads to Sentry.
Reviewed by Cursor Bugbot for commit d543fa2. Configure here.


Summary
Adds a settings-level plugin (
io.sentry.android.gradle.settings) so users can configure shared Sentry properties once insettings.gradle.ktsinstead of repeating them in every module.SentryPluginExtensionclass (previously there was a separateSentrySettingsExtensionwith duplicated properties — this was possible because the extension only neededObjectFactory, notProject)ExtraPropertiesExtensionon theGradleobject (the only shared state between settings and project scopes)Property.convention()defaults, so project-levelsentry {}overrides still take precedenceio.sentry.android.gradletolibraryandjava-librarymodulesFollows the DRY Gradle Configuration Values pattern.
User experience
🤖 Generated with Claude Code