[Crashlytics] Fix release build cache invalidation#8185
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
Reuse the on-disk id when present and valid for the current mode; only generate a new UUID on first build, after clean, or when the mode flips. This lets the task report UP_TO_DATE and stops invalidating downstream release tasks (mergeResources, R8, packaging, bundling) on every build. Fixes firebase#6770
Covers: UP_TO_DATE on second run, resource preserved across rebuilds, re-run after clean, mode-toggle invalidates the task.
Wrap the existingMappingFileId() KDoc to satisfy ktfmt.
b02cde8 to
7e1c779
Compare
| @Test | ||
| fun `injectCrashlyticsMappingFileIdRelease is UP_TO_DATE on second invocation`() { | ||
| val first = | ||
| GradleRunner.create() |
There was a problem hiding this comment.
@jrodiz we have a common method for this Gradle block, check
Crashlytics: keep release mapping file id stable across builds
injectCrashlyticsMappingFileIdReleasegenerated a new random UUID on every release build, cascading throughmergeReleaseResources→processReleaseResources→minifyReleaseWithR8→ packaging and breaking the build cache for every minified release.This PR makes the task idempotent: it reuses the on-disk id when valid for the current mode, and only mints a fresh UUID on the first build (or after
clean), or whenmappingFileUploadEnabledflips.Changes
A) Modify
InjectMappingFileIdTask.kt:useBlankMappingFileIdis false, reuse the on-disk id if non-blank; only callgenerateMappingFileId()when missing.outputs.upToDateWhen { ... }returns true when the on-disk id matches the current mode (blank vs. non-blank).blankMappingFileIdExists()withexistingMappingFileId(): String?.addGeneratedSourceDirectorywiring is unchanged — the SDK still reads the id viaCommonUtils.getMappingFileId(context).B) Added to
TypicalAppFunctionalTests.kt:is UP_TO_DATE on second invocationrelease mapping file id resource is preserved across rebuilds(byte-equality)task re-runs after cleantoggling mappingFileUploadEnabled invalidates the taskRisks / trade-offs
clean: shipping two minified releases without./gradlew cleanbetween them means both APKs share an id but have different mapping content; the second upload overwrites the first in Crashlytics. CI/CD release pipelines typically clean per release. This is the explicit trade-offinjectCrashlyticsMappingFileIdReleasecauses every release build to be invalidated #6770 accepts.cleanbehavior unchanged.Test plan
firebase-crashlytics-gradle:functionalTestand:testpass.compileKotlin,compileFunctionalTestKotlin,test— pass../gradlew assembleReleasetwice in a minified sample — task and downstream stayUP_TO_DATE.mappingFileUploadEnabled = false— task re-runs, resource becomes blank id.Verification from manual test plan above
compileSdk36,isMinifyEnabled = true, real Firebase project).com.google.firebase.crashlytics:3.0.3—mappingFileId.txtflipped every rebuild (f5f0310…→6514b43…), and:app:processReleaseResources,:app:uploadCrashlyticsMappingFileRelease,:app:packageRelease,:app:assembleReleaseall re-executed with no source changes.mavenLocal()as3.0.7and bumping the app's plugin version —mappingFileId.txtstays byte-identical across rebuilds,:app:injectCrashlyticsMappingFileIdReleasereportsUP-TO-DATE, and the full downstream cascade (:mergeReleaseResources,:processReleaseResources,:minifyReleaseWithR8,:packageRelease,:assembleRelease) isUP-TO-DATE. SecondassembleReleasefinishes in ~1s.cleanstill mints a fresh id, and togglingmappingFileUploadEnabled = falsere-runs the task and writes the blank id0…0.TEST_RESULTS_ISSUE_6770.md.Fixes #6770