Skip to content

feat(source-context): Include sources from library modules#1177

Draft
runningcode wants to merge 2 commits intomainfrom
no/source-context-all-modules
Draft

feat(source-context): Include sources from library modules#1177
runningcode wants to merge 2 commits intomainfrom
no/source-context-all-modules

Conversation

@runningcode
Copy link
Copy Markdown
Contributor

Summary

  • Source context was only collected from the app module. Stack traces from library module code had no source context in Sentry.
  • Adds support for collecting sources from all transitive local project dependencies using Gradle's consumable/resolvable configuration pattern (Project Isolation compatible).
  • Two setup paths: apply io.sentry.android.gradle to library modules directly, or apply the new io.sentry.android.gradle.settings settings plugin to auto-configure all library modules.

How it works

Library side: A consumable sentrySourceElements configuration publishes src/main/java and src/main/kotlin as artifacts with a custom attribute (io.sentry.artifact = sentry-sources).

App side: When includeSourceContext = true, a resolvable configuration inherits the same dependency scopes as RuntimeClasspath and resolves source directories from dependency libraries via attribute matching with lenient(true).

User experience

// Option A: Apply plugin to library modules
// library/build.gradle.kts
plugins {
    id("com.android.library")
    id("io.sentry.android.gradle")
}

// Option B: Use settings plugin (auto-configures all library modules)
// settings.gradle.kts
plugins {
    id("io.sentry.android.gradle.settings")
}

🤖 Generated with Claude Code

Source context was only collected from the app module, which meant stack
traces from library module code had no source context in Sentry. This
adds support for collecting sources from all transitive local project
dependencies using Gradle's consumable/resolvable configuration pattern,
which is Project Isolation compatible.

Library modules publish their source directories via a consumable
`sentrySourceElements` configuration with a custom attribute. The app
module resolves these through a resolvable configuration that inherits
the same dependency scopes as RuntimeClasspath, with lenient resolution
to gracefully skip dependencies without the plugin.

Two setup paths: apply `io.sentry.android.gradle` to library modules,
or apply the new `io.sentry.android.gradle.settings` settings plugin
to auto-configure all library modules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Include sources from library modules ([#1177](https://github.com/getsentry/sentry-android-gradle-plugin/pull/1177))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 37e4794

…ractices

Instead of the settings plugin performing build logic directly, it now
auto-applies `io.sentry.android.gradle` to library modules. The project
plugin handles all actual configuration. Follows the pattern from
liutikas.net/2024/10/28/DRY-Gradle-Configuration-Values.html.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant