11import org.apache.tools.ant.taskdefs.condition.Os
22
3+ def config = project. hasProperty(" sentry" ) ? project. sentry : [];
4+
35gradle. projectsEvaluated {
46 def releases = [];
57 android. applicationVariants. each { variant ->
@@ -24,12 +26,6 @@ gradle.projectsEvaluated {
2426 def bundleOutput = null ;
2527 def sourcemapOutput = null ;
2628 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" );
3329
3430 cmdArgs. eachWithIndex{ String arg , int i ->
3531 if (arg == " --bundle-output" ) {
@@ -50,22 +46,50 @@ gradle.projectsEvaluated {
5046 bundleTask. setProperty(" commandLine" , cmd);
5147 bundleTask. setProperty(" args" , cmdArgs);
5248
49+ if (config. flavorAware) {
50+ println " **********************************"
51+ println " * Flavor aware sentry properties *"
52+ println " **********************************"
53+ }
54+
5355 releases. each { variant , releaseName , versionCodes ->
5456 def cliTask = tasks. create(
5557 name : bundleTask. getName() + variant + " SentryUpload" ,
5658 type : Exec ) {
5759 description = " upload debug symbols to sentry"
5860
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+
5976 workingDir reactRoot
60- environment(" SENTRY_PROPERTIES" , propertiesFile)
6177
6278 def args = [
6379 cliExecutable
6480 ];
65- if (project . hasProperty( " sentryloglevel " ) ) {
81+ if (config . logLevel ) {
6682 args. push(" --log-level" );
67- args. push(sentryloglevel );
83+ args. push(config . logLevel );
6884 }
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+
6993 args. push(" react-native" );
7094 args. push(" gradle" );
7195 args. push(" --bundle" );
@@ -75,11 +99,21 @@ gradle.projectsEvaluated {
7599 args. push(" --release" );
76100 args. push(releaseName);
77101
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+
78109 versionCodes. each { versionCode ->
79110 args. add(" --dist" );
80111 args. add(versionCode);
81112 }
82113
114+ if (config. logLevel) {
115+ println args
116+ }
83117 if (Os . isFamily(Os . FAMILY_WINDOWS )) {
84118 commandLine(" cmd" , " /c" , * args)
85119 } else {
0 commit comments