@@ -27,37 +27,47 @@ class SentryPlugin implements Plugin<Project> {
2727 static String getSentryCli (Project project ) {
2828 // if a path is provided explicitly use that first
2929 def propertiesFile = " ${ project.rootDir.toPath()} /sentry.properties"
30+ project. logger. info(" propertiesFile: ${ propertiesFile} " )
31+
3032 Properties sentryProps = new Properties ()
3133 try {
3234 sentryProps. load(new FileInputStream (propertiesFile))
33- } catch (FileNotFoundException e) {
35+ } catch (FileNotFoundException ignored) {
36+ project. logger. error(ignored. getMessage())
3437 // it's okay, we can ignore it.
3538 }
3639
3740 def rv = sentryProps. getProperty(" cli.executable" )
3841 if (rv != null ) {
3942 return rv
43+ } else {
44+ project. logger. info(" cli.executable is null" )
4045 }
4146
4247 // in case there is a version from npm right around the corner use that one. This
4348 // is the case for react-native-sentry for instance
4449 def possibleExePaths = [
45- " ${ project.rootDir.toPath()} /../node_modules/@sentry/cli/bin/sentry-cli" ,
46- " ${ project.rootDir.toPath()} /../node_modules/sentry-cli-binary/bin/sentry-cli"
50+ " ${ project.rootDir.toPath()} /../node_modules/@sentry/cli/bin/sentry-cli" ,
51+ " ${ project.rootDir.toPath()} /../node_modules/sentry-cli-binary/bin/sentry-cli"
4752 ]
4853
4954 possibleExePaths. each {
5055 if ((new File (it)). exists()) {
56+ project. logger. info(" possibleExePaths: ${ it} " )
5157 return it
5258 }
5359 if ((new File (it + " .exe" )). exists()) {
60+ project. logger. info(" possibleExePaths: ${ it} .exe" )
5461 return it + " .exe"
5562 }
63+ project. logger. info(" possibleExePaths files dont exist" )
5664 }
5765
5866 // next up try a packaged version of sentry-cli
5967 def cliSuffix
6068 def osName = System . getProperty(" os.name" ). toLowerCase()
69+ project. logger. info(" osName: ${ osName} " )
70+
6171 if (osName. indexOf(" mac" ) >= 0 ) {
6272 cliSuffix = " Darwin-x86_64"
6373 } else if (osName. indexOf(" linux" ) >= 0 ) {
@@ -68,6 +78,8 @@ class SentryPlugin implements Plugin<Project> {
6878 cliSuffix = " Linux-" + arch
6979 } else if (osName. indexOf(" win" ) >= 0 ) {
7080 cliSuffix = " Windows-i686.exe"
81+ } else {
82+ project. logger. info(" cliSuffix not assigned" )
7183 }
7284
7385 if (cliSuffix != null ) {
@@ -76,12 +88,21 @@ class SentryPlugin implements Plugin<Project> {
7688
7789 // if we are not in a jar, we can use the file directly
7890 if ((new File (fsPath)). exists()) {
91+ project. logger. info(" fsPath: ${ fsPath} " )
7992 return fsPath
93+ } else {
94+ project. logger. info(" fsPath doesnt exist" )
8095 }
8196
8297 // otherwise we need to unpack into a file
8398 def resStream = SentryPlugin . class. getResourceAsStream(resPath)
8499 File tempFile = File . createTempFile(" .sentry-cli" , " .exe" )
100+ if (tempFile != null ) {
101+ project. logger. info(" tempFile: ${ tempFile.path} " )
102+ } else {
103+ project. logger. info(" tempFile is null" )
104+ }
105+
85106 tempFile. deleteOnExit()
86107 def out = new FileOutputStream (tempFile)
87108 try {
@@ -122,9 +143,9 @@ class SentryPlugin implements Plugin<Project> {
122143 */
123144 static Task getDexTask (Project project , ApplicationVariant variant ) {
124145 def names = [
125- " transformClassesWithDexFor${ variant.name.capitalize()} " ,
126- " transformClassesWithDexBuilderFor${ variant.name.capitalize()} " ,
127- " transformClassesAndDexWithShrinkResFor${ variant.name.capitalize()} "
146+ " transformClassesWithDexFor${ variant.name.capitalize()} " ,
147+ " transformClassesWithDexBuilderFor${ variant.name.capitalize()} " ,
148+ " transformClassesAndDexWithShrinkResFor${ variant.name.capitalize()} "
128149 ]
129150
130151 return names. findResult { project. tasks. findByName(it) } ?: project. tasks. findByName(" dex${ names[0]} " )
@@ -149,41 +170,81 @@ class SentryPlugin implements Plugin<Project> {
149170 * @return
150171 */
151172 static String getDebugMetaPropPath (Project project , ApplicationVariant variant ) {
173+ try {
174+ return variant. mergeAssetsProvider. get(). outputDir. get(). file(" sentry-debug-meta.properties" ). getAsFile(). path
175+ } catch (Exception ignored) {
176+ project. logger. error(" getDebugMetaPropPath 1: ${ ignored.getMessage()} " )
177+ }
178+
152179 try {
153180 return variant. mergeAssets. outputDir. get(). file(" sentry-debug-meta.properties" ). getAsFile(). path
154- } catch (Throwable ignored) {
155- return " ${ variant.mergeAssets.outputDir} /sentry-debug-meta.properties"
181+ } catch (Exception ignored) {
182+ project. logger. error(" getDebugMetaPropPath 2: ${ ignored.getMessage()} " )
183+ }
184+
185+ try {
186+ return " ${ variant.mergeAssets.outputDir.get().asFile.path} /sentry-debug-meta.properties"
187+ } catch (Exception ignored) {
188+ project. logger. error(" getDebugMetaPropPath 3: ${ ignored.getMessage()} " )
156189 }
157190
191+ try {
192+ return " ${ variant.mergeAssets.outputDir} /sentry-debug-meta.properties"
193+ } catch (Exception ignored) {
194+ project. logger. error(" getDebugMetaPropPath 4: ${ ignored.getMessage()} " )
195+ }
158196 }
159197
160198 void apply (Project project ) {
161199 SentryPluginExtension extension = project. extensions. create(" sentry" , SentryPluginExtension )
162200
163201 project. afterEvaluate {
164- if (! project. plugins. hasPlugin(AppPlugin ) && ! project. getPlugins(). hasPlugin(LibraryPlugin )) {
202+ if (! project. plugins. hasPlugin(AppPlugin ) && ! project. getPlugins(). hasPlugin(LibraryPlugin )) {
165203 throw new IllegalStateException (' Must apply \' com.android.application\' first!' )
166204 }
167205
168206 project. android. applicationVariants. all { ApplicationVariant variant ->
169207 variant. outputs. each { variantOutput ->
170208 def manifestPath = extension. manifestPath
171-
172209 if (manifestPath == null ) {
173- def dir = findAndroidManifestFileDir(variantOutput)
210+ def dir = findAndroidManifestFileDir(project, variantOutput)
211+ if (dir != null ) {
212+ project. logger. info(" manifestDir: ${ dir.path} " )
213+ } else {
214+ project. logger. info(" manifestDir is null" )
215+ }
216+
174217 manifestPath = new File (new File (dir, variantOutput. dirName), " AndroidManifest.xml" )
218+ project. logger. info(" manifestPath: ${ manifestPath} " )
219+ } else {
220+ project. logger. info(" manifestPath: ${ manifestPath} " )
175221 }
176222
177223 def mappingFile = variant. getMappingFile()
178224 def proguardTask = getProguardTask(project, variant)
225+
179226 def dexTask = getDexTask(project, variant)
227+ if (dexTask != null ) {
228+ project. logger. info(" dexTask ${ dexTask.path} " )
229+ } else {
230+ project. logger. info(" dexTask is null" )
231+ }
232+
180233 def bundleTask = getBundleTask(project, variant)
234+ if (bundleTask != null ) {
235+ project. logger. info(" bundleTask ${ bundleTask.path} " )
236+ } else {
237+ project. logger. info(" bundleTask is null" )
238+ }
181239
182240 if (proguardTask == null ) {
241+ project. logger. info(" proguardTask is null" )
183242 return
243+ } else {
244+ project. logger. info(" proguardTask ${ proguardTask.path} " )
184245 }
185246
186- // create a task to configure proguard automatically unless the user disabled it.
247+ // create a task to configure proguard automatically unless the user disabled it.
187248 if (extension. autoProguardConfig) {
188249 def addProguardSettingsTaskName = " addSentryProguardSettingsFor${ variant.name.capitalize()} "
189250 if (! project. tasks. findByName(addProguardSettingsTaskName)) {
@@ -243,15 +304,20 @@ class SentryPlugin implements Plugin<Project> {
243304
244305 if (propsFile != null ) {
245306 environment(" SENTRY_PROPERTIES" , propsFile)
307+ } else {
308+ project. logger. info(" propsFile is null" )
246309 }
247310
311+ def debugMetaPropPath = getDebugMetaPropPath(project, variant)
312+ project. logger. info(" debugMetaPropPath: ${ debugMetaPropPath} " )
313+
248314 def args = [
249315 cli,
250316 " upload-proguard" ,
251317 " --android-manifest" ,
252318 manifestPath,
253319 " --write-properties" ,
254- getDebugMetaPropPath(project, variant) ,
320+ debugMetaPropPath ,
255321 mappingFile
256322 ]
257323
@@ -296,7 +362,7 @@ class SentryPlugin implements Plugin<Project> {
296362 }
297363 }
298364
299- static File findAndroidManifestFileDir (BaseVariantOutput variantOutput ) {
365+ static File findAndroidManifestFileDir (Project project , BaseVariantOutput variantOutput ) {
300366 // Gradle 4.7 introduced the lazy task API and AGP 3.3+ adopts that,
301367 // so we apparently have a Provider<File> here instead
302368 // TODO: This will let us depend on the configuration of each flavor's
@@ -307,14 +373,34 @@ class SentryPlugin implements Plugin<Project> {
307373
308374 try { // Android Gradle Plugin >= 3.3.0
309375 return variantOutput. processManifestProvider. get(). manifestOutputDirectory. get(). asFile
310- } catch (Exception ignored) {}
376+ } catch (Exception ignored) {
377+ project. logger. error(" findAndroidManifestFileDir 1: ${ ignored.getMessage()} " )
378+ }
311379
312380 try { // Android Gradle Plugin >= 3.0.0
313381 return variantOutput. processManifest. manifestOutputDirectory. get(). asFile
314- } catch (Exception ignored) {}
382+ } catch (Exception ignored) {
383+ project. logger. error(" findAndroidManifestFileDir 2: ${ ignored.getMessage()} " )
384+ }
315385
316- try { // Android Gradle Plugin < 3.0.0
386+ // Android Gradle Plugin < 3.0.0
387+ try {
317388 return new File (variantOutput. processManifest. manifestOutputFile). parentFile
318- } catch (Exception ignored) {}
389+ } catch (Exception ignored) {
390+ project. logger. error(" findAndroidManifestFileDir 3: ${ ignored.getMessage()} " )
391+ }
392+
393+ // https://github.com/Tencent/tinker/pull/620/files
394+ try {
395+ return variantOutput. processResourcesProvider. get(). manifestFile. parentFile
396+ } catch (Exception ignored) {
397+ project. logger. error(" findAndroidManifestFileDir 4: ${ ignored.getMessage()} " )
398+ }
399+
400+ try {
401+ return variantOutput. processResources. manifestFile. parentFile
402+ } catch (Exception ignored) {
403+ project. logger. error(" findAndroidManifestFileDir 5: ${ ignored.getMessage()} " )
404+ }
319405 }
320406}
0 commit comments