Skip to content

Commit 7d293fd

Browse files
fabiendemclaude
andcommitted
fix(android): consult overridable auto-upload closure at config time
Addresses review feedback: capturing `SENTRY_DISABLE_AUTO_UPLOAD` via `System.getenv` at apply-time ignored a `project.ext.shouldSentryAutoUploadGeneral` override set right after `apply from` (e.g. the Expo `disableAutoUpload` config plugin, which injects `project.ext.shouldSentryAutoUploadGeneral = { -> return false }`). Uploads would then run even when the user disabled them. Now capture `shouldSentryAutoUploadGeneral()` inside the `onVariants` callback, which runs after the app `build.gradle` has evaluated, so the override is in effect. Likewise capture `shouldCopySentryOptionsFile()` via the closure rather than re-reading the env var, so `project.ext` overrides of it keep working. Both `onlyIf` specs still reference a captured boolean, so the tasks remain Configuration Cache compatible, and the original override behavior is restored. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 2a1daaa commit 7d293fd

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/core/sentry.gradle.kts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ val androidAssetsDir = File("$rootDir/app/src/main/assets")
107107

108108
// Values captured at configuration time so task onlyIf specs and actions do not read
109109
// `project` state at execution time (required for Gradle Configuration Cache compatibility).
110-
val copyOptionsFileEnabled = System.getenv("SENTRY_COPY_OPTIONS_FILE") != "false"
111-
val sentryAutoUploadGeneralEnabled = System.getenv("SENTRY_DISABLE_AUTO_UPLOAD") != "true"
110+
// The overridable `shouldCopySentryOptionsFile()` closure is still consulted (not the env var
111+
// directly) so setups that reassign `project.ext.shouldCopySentryOptionsFile` keep working.
112+
val copyOptionsFileEnabled = shouldCopySentryOptionsFile()
112113
val rootDirFile = project.rootDir
113114

114115
tasks.register("copySentryJsonConfiguration") {
@@ -503,6 +504,12 @@ fun processVariant(v: Any) {
503504
val vName = v.javaClass.getMethod("getName").invoke(v) as String
504505
if (vName.contains("debug", ignoreCase = true)) return
505506

507+
// Captured here (inside the onVariants callback, which runs after the app build.gradle has
508+
// evaluated) rather than at apply-time, so a `project.ext.shouldSentryAutoUploadGeneral`
509+
// override set right after `apply from` (e.g. the Expo `disableAutoUpload` plugin) is honored.
510+
// Referencing this captured boolean in `onlyIf` keeps the task Configuration Cache compatible.
511+
val sentryAutoUploadGeneralEnabled = shouldSentryAutoUploadGeneral()
512+
506513
val variantCapitalized = Character.toUpperCase(vName[0]).toString() + vName.substring(1)
507514
val sentryBundleTaskName =
508515
listOf(

0 commit comments

Comments
 (0)