diff --git a/examples/android-instrumentation-sample/build.gradle.kts b/examples/android-instrumentation-sample/build.gradle.kts index a6e3821a..9dad2e69 100644 --- a/examples/android-instrumentation-sample/build.gradle.kts +++ b/examples/android-instrumentation-sample/build.gradle.kts @@ -108,6 +108,7 @@ sentry { includeSourceContext.set(true) autoUploadSourceContext.set(CI.canAutoUpload()) + autoUploadSourceContextBuildTypes.set(setOf("debug", "release")) additionalSourceDirsForSourceContext.set(setOf("src/custom/java")) org.set("sentry-sdks") diff --git a/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt b/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt index 745106b4..c49a57e6 100644 --- a/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt +++ b/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt @@ -305,10 +305,9 @@ private fun Variant.configureSourceBundleTasks( taskSuffix ) - if (variant.buildTypeName == "release") { + if (extension.autoUploadSourceContextBuildTypes.get().contains(variant.buildTypeName)) { sourceContextTasks.uploadSourceBundleTask.hookWithAssembleTasks(project, variant) } - return sourceContextTasks } else { project.logger.info { diff --git a/plugin-build/src/main/kotlin/io/sentry/android/gradle/AppConfig.kt b/plugin-build/src/main/kotlin/io/sentry/android/gradle/AppConfig.kt index e40cd9ea..51ae8655 100644 --- a/plugin-build/src/main/kotlin/io/sentry/android/gradle/AppConfig.kt +++ b/plugin-build/src/main/kotlin/io/sentry/android/gradle/AppConfig.kt @@ -228,7 +228,7 @@ private fun ApplicationVariant.configureSourceBundleTasks( taskSuffix ) - if (variant.buildTypeName == "release") { + if (extension.autoUploadSourceContextBuildTypes.get().contains(variant.buildTypeName)) { sourceContextTasks.uploadSourceBundleTask.hookWithAssembleTasks(project, variant) } diff --git a/plugin-build/src/main/kotlin/io/sentry/android/gradle/extensions/SentryPluginExtension.kt b/plugin-build/src/main/kotlin/io/sentry/android/gradle/extensions/SentryPluginExtension.kt index 17ea100e..6701d302 100644 --- a/plugin-build/src/main/kotlin/io/sentry/android/gradle/extensions/SentryPluginExtension.kt +++ b/plugin-build/src/main/kotlin/io/sentry/android/gradle/extensions/SentryPluginExtension.kt @@ -156,6 +156,13 @@ abstract class SentryPluginExtension @Inject constructor(project: Project) { val autoUploadSourceContext: Property = objects .property(Boolean::class.java).convention(true) + /** + * Which build types should be considered for automatic source context upload. + * Default is "release" only. + */ + val autoUploadSourceContextBuildTypes: SetProperty = objects + .setProperty(String::class.java).convention(setOf("release")) + /** * Configure additional directories to be included in the source bundle which is used for * source context. The directories should be specified relative to the Gradle module/project's