From b30ad5c08cd7ef798c4e47f1a38511397e8cbb7a Mon Sep 17 00:00:00 2001 From: Shaygan Hooshyari Date: Fri, 12 Jan 2024 11:42:36 +0100 Subject: [PATCH] Disable sourceContext option to make build work. (#8497) * Disable sourceContext option to make build work. When setting this option to true, `authToken`, `org`, and `project` settings also need to be set. Documentation for setting them exists in the source context documentation. * Add section for running sentry task after code gen. Fix: https://github.com/getsentry/sentry-android-gradle-plugin/issues/546 * some minor changes; re-enable source context in sample * Apply suggestions from code review Co-authored-by: Shana Matthews * lint fix --------- Co-authored-by: Alexander Dinauer Co-authored-by: Alexander Dinauer Co-authored-by: Shana Matthews --- src/platform-includes/source-context/java.mdx | 24 +++++++++++++++++++ src/platforms/java/common/gradle/index.mdx | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/platform-includes/source-context/java.mdx b/src/platform-includes/source-context/java.mdx index 820dfb4bfc2f3..5fd002b9f007c 100644 --- a/src/platform-includes/source-context/java.mdx +++ b/src/platform-includes/source-context/java.mdx @@ -221,6 +221,30 @@ sentry { +### Source Context for Generated Code + +If you have a code generation step in your build (e.g. Quarkus) you will see an error similar to this: + +``` +Task ':xxx:sentryCollectSourcesJava' uses this output of task ':xxx:quarkusGenerateCode' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. +``` + +To resolve this, declare a task dependency for `sentryCollectSourcesJava` on code generation tasks that exist in your build: + +```groovy +tasks.named("sentryCollectSourcesJava") { + // Make the task run after the tasks that generate code during build + mustRunAfter("CodeGenTask1", "CodeGenTask2") +} +``` + +```kotlin +tasks.named("sentryCollectSourcesJava") { + // Make the task run after the tasks that generate code during build + mustRunAfter("CodeGenTask1", "CodeGenTask2") +} +``` + ## Using the Maven Build Tool Plugin diff --git a/src/platforms/java/common/gradle/index.mdx b/src/platforms/java/common/gradle/index.mdx index 3690343198d51..36a9c598dcbb2 100644 --- a/src/platforms/java/common/gradle/index.mdx +++ b/src/platforms/java/common/gradle/index.mdx @@ -50,7 +50,7 @@ sentry { // This enables source context, allowing you to see your source // code as part of your stack traces in Sentry. // - // Default is disabled. + // Default is disabled. To enable, see the source context guide. includeSourceContext = true // Includes additional source directories into the source bundle. @@ -83,7 +83,7 @@ sentry { // This enables source context, allowing you to see your source // code as part of your stack traces in Sentry. // - // Default is disabled. + // Default is disabled. To enable, see the source context guide. includeSourceContext.set(true) // Includes additional source directories into the source bundle.