Skip to content

chore(samples-android): Support mavenLocal for builds that apply the SAGP#5539

Open
0xadam-brown wants to merge 1 commit into
chore/use-sagp-with-sample-android-appfrom
chore/maven-local-with-sample-android-app
Open

chore(samples-android): Support mavenLocal for builds that apply the SAGP#5539
0xadam-brown wants to merge 1 commit into
chore/use-sagp-with-sample-android-appfrom
chore/maven-local-with-sample-android-app

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Jun 12, 2026

Copy link
Copy Markdown
Member

Follow-on to #5538

📜 Description

Adds wiring that lets us prefer mavenLocal SAGP artifacts, when present, for Android sample app builds that set -PuseSagp=true. If no local artifact is found, we fall back to libs.versions.toml.

💡 Motivation and Context

Lets us use local / under-development versions of SAGP with the Android sample app.

Output

Logs the provenance of the SAGP artifact so developers don't forget they have a Maven Local version that's getting picked up:

Build applied mavenLocal SAGP

mavenLocal

Build applied remote / libs.versions.toml SAGP

Remote

💚 How did you test it?

Manually.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@sentry

sentry Bot commented Jun 12, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.43.2 (1) release

⚙️ sentry-android Build Distribution Settings

…SAGP

Adds wiring that lets us prefer mavenLocal SAGP artifacts, when present, for Android sample app builds that set -PuseSagp=true. If no local artifact is found, we fall back to libs.versions.toml.
@0xadam-brown 0xadam-brown force-pushed the chore/maven-local-with-sample-android-app branch from 1ef72b0 to f521ffd Compare June 12, 2026 09:54
@0xadam-brown 0xadam-brown changed the title chore(samples-android): Resolve SAGP from mavenLocal for -PuseSagp builds chore(samples-android): Support mavenLocal for builds that apply the SAGP Jun 12, 2026
@0xadam-brown 0xadam-brown marked this pull request as ready for review June 12, 2026 09:54

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f521ffd. Configure here.

Comment thread settings.gradle.kts
pluginManagement {
repositories {
// Prefer local SAGP artifact if one exists; otherwise fall back to libs.versions.toml.
if (providers.gradleProperty("useSagp").orNull.equals("true", ignoreCase = true)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing useSagp property NPE

High Severity

When useSagp is absent, providers.gradleProperty("useSagp").orNull is null and calling .equals("true", …) on that receiver throws a null-pointer exception during settings evaluation, so default builds without the property can fail before configuration.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f521ffd. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is true.

sagpVersion == null -> "unknown origin"
sagpLocalJar?.isFile == true ->
"mavenLocal (published ${Instant.ofEpochMilli(sagpLocalJar.lastModified())})"
else -> "remote repository"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAGP origin log misleading

Low Severity

logSagpOrigin labels the plugin as mavenLocal whenever a matching JAR exists under ~/.m2, even when Gradle actually loaded SAGP from a remote cache, so the lifecycle message can misstate which artifact was applied.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f521ffd. Configure here.

Comment thread gradle/libs.versions.toml
otelSemanticConventions = "1.40.0"
otelSemanticConventionsAlpha = "1.40.0-alpha"
retrofit = "2.9.0"
sagp = "6.6.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use 6.10.0?

sagpVersion?.let {
File(
System.getProperty("user.home"),
".m2/repository/io/sentry/sentry-android-gradle-plugin/$it/sentry-android-gradle-plugin-$it.jar",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if we can rely on the artifact always being here? This seems prone to breaking.

Is this configuration cache compatible?

Comment thread settings.gradle.kts
pluginManagement {
repositories {
// Prefer local SAGP artifact if one exists; otherwise fall back to libs.versions.toml.
if (providers.gradleProperty("useSagp").orNull.equals("true", ignoreCase = true)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is true.


fun Project.logSagpOrigin() {
// A locally published SAGP in ~/.m2 silently shadows the released artifact (see README,
// "Testing an unpublished SAGP build"); we log so developers don't wonder what's going on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems prone to breaking. I would just make sure to use a unique version for publishing and then you are sure that you are using it.
If you are still unsure you can check a build scan to verify where it came from.

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.

2 participants