build(samples): Move the Android sample to its own composite build - #6047
Draft
runningcode wants to merge 1 commit into
Draft
build(samples): Move the Android sample to its own composite build#6047runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
The Android sample was a subproject of the SDK build, so every root Gradle invocation configured AGP, Compose, KSP, SQLDelight, Room and CameraX, and the sample consumed the SDK through project accessors rather than as a real consumer would. It is now a standalone build that includes the SDK build, depending on plain io.sentry:* coordinates that Gradle substitutes with the SDK's projects. Run it with ./gradlew -p sentry-samples/sentry-samples-android <task>. The macrobenchmark module moves along with it, because AGP requires a benchmark's target app to live in the same build. The AGP version moves to the version catalog so both builds share one source of truth, still overridable via VERSION_AGP. The SDK build includes the sample build back, so a single ./gradlew spotlessApply still formats the whole repository and CI needs no sample-specific step. Root check does not reach the sample, so preMerge gains a checkSampleAndroid target. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
📲 Install BuildsAndroid
|
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.
📜 Description
sentry-samples/sentry-samples-androidbecomes a standalone Gradle build that includes the SDK build, instead of being a subproject of it.The sample's nine
projects.sentryXaccessors become plainio.sentry:*coordinates, which Gradle substitutes back to the SDK's projects — so nothing needs to be published first:Run it with
./gradlew -p sentry-samples/sentry-samples-android <task>, or open that directory in Android Studio.Notable details:
sentry-uitest-android-macrobenchmarkmoves into the sample build assentry-samples-android/macrobenchmark, because AGP requires a benchmark's target app to live in the same build. The app is that build's root project andtargetProjectPath = ":"works, so the app's own files did not have to move. Its APK path changes (Sauce config updated); the sample's own APK path is unchanged.gradle/libs.versions.toml(agp = "9.2.1"), shared by both builds, replacingConfig.AGPand the rootbuildscriptclasspath.VERSION_AGPstill overrides it, through apluginManagementresolution strategy in each settings file.versionNameout of the root build'sgradle.propertiesrather than duplicating it, so an APK still records which SDK it was built against../gradlew spotlessApplystill formats the whole repository — no CI or contributor-facing formatting changes were needed. The sample build's rootspotlessApplyfans out to its own subprojects, so the root build does not enumerate the sample's modules.make preMergegainscheckSampleAndroid(assembleDebug lintDebugin the sample build), since rootcheckno longer reaches the sample. Folding it into rootcheckinstead would put an Android app build back into the SDK build's gate.Two things worth a second opinion:
build --dry-run --no-configuration-cache, i.e. inside run-to-run noise, and no sample tasks execute. Not zero coupling, but not measurable either..javafiles lose the root build's-Xlint:all -Werrorjavac flags, which came from the rootallprojectsblock. I did not replicate them for a sample app.💡 Motivation and Context
While the sample was a subproject of the SDK build, every root Gradle invocation (
check,apiDump,spotlessApply) configured it, dragging AGP, Compose, KSP, SQLDelight, Room and CameraX into the SDK build's graph. The sample also consumed the SDK through project accessors, so it never exercised it the way a real consumer does, and it could not be built or opened independently of the whole SDK build.💚 How did you test it?
dependencies --configuration debugRuntimeClasspathin the sample build, confirming everyio.sentry:*dependency resolves to a project of the included build (including the KMPsentry-compose).assembleDebug,assembleRelease(exercises R8 andproguard-rules.pro),:macrobenchmark:assembleBenchmark, andmake checkSampleAndroidin the sample build.apiDump(no.apidrift),spotlessApply(no changes), andmake assembleUiTests, the command the AGP matrix job runs.VERSION_AGP: 9.2.1 by default and 9.0.0 under the env var, in both builds.MyApplication.java(app) andSentryStartupBenchmark.kt(macrobenchmark), then confirmed root./gradlew spotlessApplyfixed both.Not verified locally:
-PuseSagp(the catalog pins SAGP 6.13.0, which needs a local SAGP build) and installing on a device. On the first of those, the build root is now the sample directory, which has nosentry.properties; that should not matter because the sample setsincludeProguardMapping=falseandtelemetry=false, but that is reasoning rather than a test.📝 Checklist
sendDefaultPIIis enabled.apiDumpis clean🔮 Next steps
If the cold-configuration coupling in point 1 above is unwelcome, the alternative is to drop
includeBuild("sentry-samples/sentry-samples-android")from the root settings and give the root build its own spotless targets covering the sample's paths, at the cost of duplicating the format rules.make checkFormatrunsspotlessJavaCheck spotlessKotlinCheck, which are per-project task names and so do not reach included builds. Left alone here rather than change which formats that target checks; a root-levelspotlessCheckcould delegate the same wayspotlessApplynow does, if wanted.#skip-changelog