11import org.apache.tools.ant.taskdefs.condition.Os
22
33gradle. projectsEvaluated {
4- // to find out which releases are being generated we hook into the process
5- // resources task. From the "assetsDir" property we can extract in which
6- // assets folder the task is operating. This folder matches where react native
7- // will place the bundles.
8- def releasesForFolder = [:];
4+ def releases = [];
95 android. applicationVariants. each { variant ->
106 def releaseName = " ${ variant.getApplicationId()} -${ variant.getVersionName()} " ;
117 variant. outputs. each { output ->
128 def processTask = output. getProcessResources();
13- def resDir = processTask. getResDir();
14- def releases = releasesForFolder. get(resDir. toString()) as List<String > ;
15- if (releases == null ) {
16- releases = [];
17- releasesForFolder. put(resDir. toString(), releases);
18- }
199 def versionCode = output. getVersionCode();
20- releases. add([releaseName, versionCode]);
10+ releases. add([output . getName(), releaseName, versionCode]);
2111 }
2212 }
2313
@@ -28,27 +18,6 @@ gradle.projectsEvaluated {
2818 task. name. startsWith(" bundle" ) && task. name. endsWith(" JsAndAssets" )
2919 }
3020 bundleTasks. each { bundleTask ->
31- def outputs = bundleTask. getOutputs();
32- def allReleases = [:];
33- outputs. getFiles(). each { file ->
34- def releases = releasesForFolder. get(file. toString());
35- if (releases != null ) {
36- releases. each { item ->
37- def codes = allReleases[item[0 ]] as List<String > ;
38- if (codes == null ) {
39- codes = [];
40- allReleases[item[0 ]] = codes;
41- }
42- codes. add(item[1 ]);
43- }
44- }
45- }
46-
47- // this really should not happen but better be safe than sorry.
48- if (allReleases. size() == 0 ) {
49- return ;
50- }
51-
5221 def props = bundleTask. getProperties();
5322 def cmd = props. get(" commandLine" ) as List<String > ;
5423 def cmdArgs = props. get(" args" ) as List<String > ;
@@ -81,22 +50,30 @@ gradle.projectsEvaluated {
8150 bundleTask. setProperty(" commandLine" , cmd);
8251 bundleTask. setProperty(" args" , cmdArgs);
8352
84- allReleases . each { releaseName , versionCodes ->
53+ releases . each { variant , releaseName , versionCodes ->
8554 def cliTask = tasks. create(
86- name : bundleTask. getName() + " SentryUpload" ,
55+ name : bundleTask. getName() + variant + " SentryUpload" ,
8756 type : Exec ) {
8857 description = " upload debug symbols to sentry"
8958
9059 workingDir reactRoot
9160 environment(" SENTRY_PROPERTIES" , propertiesFile)
61+
9262 def args = [
93- cliExecutable,
94- " react-native" ,
95- " gradle" ,
96- " --bundle" , bundleOutput,
97- " --sourcemap" , sourcemapOutput,
98- " --release" , releaseName
63+ cliExecutable
9964 ];
65+ if (project. hasProperty(" sentryloglevel" ) ) {
66+ args. push(" --log-level" );
67+ args. push(sentryloglevel);
68+ }
69+ args. push(" react-native" );
70+ args. push(" gradle" );
71+ args. push(" --bundle" );
72+ args. push(bundleOutput);
73+ args. push(" --sourcemap" );
74+ args. push(sourcemapOutput);
75+ args. push(" --release" );
76+ args. push(releaseName);
10077
10178 versionCodes. each { versionCode ->
10279 args. add(" --dist" );
0 commit comments