@@ -3,7 +3,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
3
3
import java.util.regex.Matcher
4
4
import java.util.regex.Pattern
5
5
6
- project. ext. shouldSentryAutoUploadNative = { ->
6
+ project. ext. shouldSentryAutoUploadNative = { ->
7
7
return System . getenv(' SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD' ) != ' true'
8
8
}
9
9
@@ -17,13 +17,13 @@ project.ext.shouldSentryAutoUpload = { ->
17
17
18
18
def config = project. hasProperty(" sentryCli" ) ? project. sentryCli : [];
19
19
20
+ def configFile = " sentry.options.json" // Sentry condiguration file
21
+ def androidAssetsDir = new File (" $rootDir /app/src/main/assets" ) // Path to Android assets folder
22
+
20
23
tasks. register(" copySentryJsonConfiguration" ) {
21
24
doLast {
22
- def configFile = " sentry.options.json"
23
25
def appRoot = project. rootDir. parentFile ?: project. rootDir
24
26
def sentryOptionsFile = new File (appRoot, configFile)
25
- def androidAssetsDir = new File (" $rootDir /app/src/main/assets" ) // Path to Android assets folder
26
-
27
27
if (sentryOptionsFile. exists()) {
28
28
if (! androidAssetsDir. exists()) {
29
29
androidAssetsDir. mkdirs()
@@ -41,11 +41,27 @@ tasks.register("copySentryJsonConfiguration") {
41
41
}
42
42
}
43
43
44
+ tasks. register(" cleanupTemporarySentryJsonConfiguration" ) {
45
+ doLast {
46
+ def sentryOptionsFile = new File (androidAssetsDir, configFile)
47
+ if (sentryOptionsFile. exists()) {
48
+ logger. lifecycle(" Deleting temporary file: ${ sentryOptionsFile.path} " )
49
+ sentryOptionsFile. delete()
50
+ }
51
+ }
52
+ }
53
+
44
54
gradle. projectsEvaluated {
45
55
// Add a task that copies the sentry.options.json file before the build starts
46
56
tasks. named(" preBuild" ). configure {
47
57
dependsOn(" copySentryJsonConfiguration" )
48
58
}
59
+ // Cleanup sentry.options.json from assets after the build
60
+ tasks. matching { task ->
61
+ task. name == " build" || task. name. startsWith(" assemble" ) || task. name. startsWith(" install" )
62
+ }. configureEach {
63
+ finalizedBy(" cleanupTemporarySentryJsonConfiguration" )
64
+ }
49
65
50
66
def releases = extractReleasesInfo()
51
67
0 commit comments