1
1
import org.apache.tools.ant.taskdefs.condition.Os
2
2
3
+ def config = project. hasProperty(" sentry" ) ? project. sentry : [];
4
+
3
5
gradle. projectsEvaluated {
4
6
def releases = [];
5
7
android. applicationVariants. each { variant ->
@@ -24,12 +26,6 @@ gradle.projectsEvaluated {
24
26
def bundleOutput = null ;
25
27
def sourcemapOutput = null ;
26
28
def reactRoot = props. get(" workingDir" );
27
- def propertiesFile = " $reactRoot /android/sentry.properties" ;
28
- Properties sentryProps = new Properties ();
29
- try {
30
- sentryProps. load(new FileInputStream (propertiesFile));
31
- } catch (FileNotFoundException e) {}
32
- def cliExecutable = sentryProps. get(" cli.executable" , " $reactRoot /node_modules/sentry-cli-binary/bin/sentry-cli" );
33
29
34
30
cmdArgs. eachWithIndex{ String arg , int i ->
35
31
if (arg == " --bundle-output" ) {
@@ -50,22 +46,50 @@ gradle.projectsEvaluated {
50
46
bundleTask. setProperty(" commandLine" , cmd);
51
47
bundleTask. setProperty(" args" , cmdArgs);
52
48
49
+ if (config. flavorAware) {
50
+ println " **********************************"
51
+ println " * Flavor aware sentry properties *"
52
+ println " **********************************"
53
+ }
54
+
53
55
releases. each { variant , releaseName , versionCodes ->
54
56
def cliTask = tasks. create(
55
57
name : bundleTask. getName() + variant + " SentryUpload" ,
56
58
type : Exec ) {
57
59
description = " upload debug symbols to sentry"
58
60
61
+ def propertiesFile = " $reactRoot /android/sentry.properties" ;
62
+ if (config. flavorAware) {
63
+ propertiesFile = " $reactRoot /android/sentry-$variant " + " .properties"
64
+ println " For $variant using: $propertiesFile "
65
+ } else {
66
+ environment(" SENTRY_PROPERTIES" , propertiesFile)
67
+ }
68
+ Properties sentryProps = new Properties ();
69
+ try {
70
+ sentryProps. load(new FileInputStream (propertiesFile));
71
+ } catch (FileNotFoundException e) {
72
+ println " File not found: $propertiesFile "
73
+ }
74
+ def cliExecutable = sentryProps. get(" cli.executable" , " $reactRoot /node_modules/sentry-cli-binary/bin/sentry-cli" );
75
+
59
76
workingDir reactRoot
60
- environment(" SENTRY_PROPERTIES" , propertiesFile)
61
77
62
78
def args = [
63
79
cliExecutable
64
80
];
65
- if (project . hasProperty( " sentryloglevel " ) ) {
81
+ if (config . logLevel ) {
66
82
args. push(" --log-level" );
67
- args. push(sentryloglevel );
83
+ args. push(config . logLevel );
68
84
}
85
+
86
+ if (config. flavorAware) {
87
+ args. push(" --url" );
88
+ args. push(sentryProps. get(" defaults.url" ));
89
+ args. push(" --auth-token" );
90
+ args. push(sentryProps. get(" auth.token" ));
91
+ }
92
+
69
93
args. push(" react-native" );
70
94
args. push(" gradle" );
71
95
args. push(" --bundle" );
@@ -75,11 +99,21 @@ gradle.projectsEvaluated {
75
99
args. push(" --release" );
76
100
args. push(releaseName);
77
101
102
+ if (config. flavorAware) {
103
+ args. push(" --org" );
104
+ args. push(sentryProps. get(" defaults.org" ));
105
+ args. push(" --project" );
106
+ args. push(sentryProps. get(" defaults.project" ));
107
+ }
108
+
78
109
versionCodes. each { versionCode ->
79
110
args. add(" --dist" );
80
111
args. add(versionCode);
81
112
}
82
113
114
+ if (config. logLevel) {
115
+ println args
116
+ }
83
117
if (Os . isFamily(Os . FAMILY_WINDOWS )) {
84
118
commandLine(" cmd" , " /c" , * args)
85
119
} else {
0 commit comments