-
-
Notifications
You must be signed in to change notification settings - Fork 472
chore(samples-android): Support mavenLocal for builds that apply the SAGP #5539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: chore/use-sagp-with-sample-android-app
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ import com.android.build.api.artifact.SingleArtifact | |
| import com.android.build.api.variant.impl.VariantImpl | ||
| import io.sentry.android.gradle.extensions.InstrumentationFeature | ||
| import io.sentry.android.gradle.extensions.SentryPluginExtension | ||
| import java.io.File | ||
| import java.time.Instant | ||
| import org.apache.tools.ant.taskdefs.condition.Os | ||
| import org.gradle.internal.extensions.stdlib.capitalized | ||
|
|
||
|
|
@@ -20,6 +22,8 @@ if (useSagp.get()) { | |
| } | ||
|
|
||
| plugins.withId("io.sentry.android.gradle") { | ||
| logSagpOrigin() | ||
|
|
||
| // Extension configs match non-SAGP builds. Update locally to test your feature. | ||
| extensions.configure<SentryPluginExtension>("sentry") { | ||
| autoInstallation.enabled.set(false) | ||
|
|
@@ -230,3 +234,46 @@ abstract class ToggleNativeLoggingTask : Exec() { | |
| ) | ||
| } | ||
| } | ||
|
|
||
| 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| val sagpVersion = | ||
| SentryPluginExtension::class | ||
| .java | ||
| .protectionDomain | ||
| .codeSource | ||
| ?.location | ||
| ?.toURI() | ||
| ?.let { File(it).name } | ||
| ?.removePrefix("sentry-android-gradle-plugin-") | ||
| ?.removeSuffix(".jar") | ||
|
|
||
| val sagpLocalJar = | ||
| sagpVersion?.let { | ||
| File( | ||
| System.getProperty("user.home"), | ||
| ".m2/repository/io/sentry/sentry-android-gradle-plugin/$it/sentry-android-gradle-plugin-$it.jar", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| ) | ||
| } | ||
|
|
||
| val sagpOrigin = | ||
| when { | ||
| sagpVersion == null -> "unknown origin" | ||
| sagpLocalJar?.isFile == true -> | ||
| "mavenLocal (published ${Instant.ofEpochMilli(sagpLocalJar.lastModified())})" | ||
| else -> "remote repository" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SAGP origin log misleadingLow Severity
Reviewed by Cursor Bugbot for commit f521ffd. Configure here. |
||
| } | ||
|
|
||
| val colorize = | ||
| gradle.startParameter.consoleOutput != org.gradle.api.logging.configuration.ConsoleOutput.Plain | ||
| val (magenta, reset) = if (colorize) "\u001B[35m" to "\u001B[0m" else "" to "" | ||
|
|
||
| logger.lifecycle( | ||
| "\n{}🧩 Applied Sentry Android Gradle Plugin {} from {}{}", | ||
| magenta, | ||
| sagpVersion ?: "<unknown version>", | ||
| sagpOrigin, | ||
| reset, | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,15 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") | |
|
|
||
| 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)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing useSagp property NPEHigh Severity When Reviewed by Cursor Bugbot for commit f521ffd. Configure here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is true. |
||
| mavenLocal { | ||
| content { | ||
| includeGroup("io.sentry") | ||
| includeGroup("io.sentry.android.gradle") | ||
| } | ||
| } | ||
| } | ||
| mavenCentral() | ||
| gradlePluginPortal() | ||
| } | ||
|
|
||


There was a problem hiding this comment.
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?