From 9ec65d6e7e0b8fa50f8db178505e642082c3c8d6 Mon Sep 17 00:00:00 2001 From: Sim Sun Date: Mon, 22 Apr 2019 11:12:26 -0700 Subject: [PATCH] fix(core): use try catch to assign outputFile value fix #323 fix #324 --- .../com/tencent/gradle/AndResGuardTask.groovy | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy b/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy index 7fe73b38..102b626d 100644 --- a/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy +++ b/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy @@ -37,11 +37,15 @@ class AndResGuardTask extends DefaultTask { variant.productFlavors, variant.buildType.name) || variantName.equalsIgnoreCase(AndResGuardPlugin.USE_APK_TASK_NAME)) { - def outputFile - if (variant.metaClass.respondsTo(variant, "getPackageApplicationProvider")) { - outputFile = { File(variant.packageApplicationProvider.get().outputDirectory, output.outputFileName) } - } else { - outputFile = output.outputFile + def outputFile = null + try { + if (variant.metaClass.respondsTo(variant, "getPackageApplicationProvider")) { + outputFile = new File(variant.packageApplicationProvider.get().outputDirectory, output.outputFileName) + } + } catch (Exception ignore) { + // no-op + } finally { + outputFile = outputFile ?: output.outputFile } buildConfigs << new BuildInfo(