diff --git a/build.gradle b/build.gradle index cbc1dc4..4e6fc69 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group 'com.stringcare' -version '3.4' +version '3.5' def siteUrl = 'https://github.com/StringCare/KotlinGradlePlugin' def gitUrl = 'https://github.com/StringCare/KotlinGradlePlugin.git' diff --git a/src/main/kotlin/StringCare.kt b/src/main/kotlin/StringCare.kt index 291118a..403ef5b 100644 --- a/src/main/kotlin/StringCare.kt +++ b/src/main/kotlin/StringCare.kt @@ -25,6 +25,9 @@ open class StringCare : Plugin { @JvmStatic internal val moduleMap: MutableMap = mutableMapOf() + @JvmStatic + internal val variantMap: MutableMap = mutableMapOf() + @JvmStatic internal var mainModule: String = defaultMainModule @@ -63,6 +66,13 @@ open class StringCare : Plugin { moduleMap[module.name]!!.stringFiles.addAll(defaultConfig().stringFiles) } } + extension.variants.forEach { variant -> + variantMap[variant.name] = VariantApplicationId(variant.name).apply { + applicationId = variant.applicationId + mockedFingerprint = variant.mockedFingerprint + skip = variant.skip + } + } this.project.registerTask() } this.project.gradle.addBuildListener(ExecutionListener( @@ -71,7 +81,7 @@ open class StringCare : Plugin { // nothing to do here }, mergeResourcesStart = { module, variant -> - fingerPrint(module, variant, extension.debug) { key -> + fingerPrint(variantMap, module, variant, extension.debug) { key -> if ("none" == key) { return@fingerPrint } @@ -130,7 +140,7 @@ open class StringCare : Plugin { restoreResourceFiles(absoluteProjectPath, module) }, mergeAssetsStart = { module, variant -> - fingerPrint(module, variant, extension.debug) { key -> + fingerPrint(variantMap, module, variant, extension.debug) { key -> if ("none" == key) { return@fingerPrint } @@ -213,6 +223,7 @@ open class StringCare : Plugin { open class VariantApplicationId(var name: String) { var applicationId = "" + var mockedFingerprint = "" var skip = false } diff --git a/src/main/kotlin/components/Fingerprint.kt b/src/main/kotlin/components/Fingerprint.kt index abfdf8e..c8f86e3 100644 --- a/src/main/kotlin/components/Fingerprint.kt +++ b/src/main/kotlin/components/Fingerprint.kt @@ -75,7 +75,13 @@ private class Fingerprint { /** * Gets the signing report trace and extracts the fingerprint */ -fun fingerPrint(module: String, variant: String, debug: Boolean, keyFound: (key: String) -> Unit) { +fun fingerPrint(variantMap: MutableMap, module: String, variant: String, debug: Boolean, keyFound: (key: String) -> Unit) { + if (variantMap.containsKey(variant)) { + if (variantMap[variant]!!.mockedFingerprint.isNotEmpty()) { + keyFound(variantMap[variant]!!.mockedFingerprint) + return + } + } signingReportTask().runCommand { _, report -> keyFound(report.extractFingerprint(module, variant, debug)) } diff --git a/src/main/kotlin/components/Vars.kt b/src/main/kotlin/components/Vars.kt index 3788166..8e6fea5 100644 --- a/src/main/kotlin/components/Vars.kt +++ b/src/main/kotlin/components/Vars.kt @@ -2,7 +2,7 @@ package components import java.io.File -internal const val version = "3.3" +internal const val version = "3.5" internal const val testProjectName = "KotlinSample" internal const val defaultDebug = false internal const val defaultMainModule = "app" diff --git a/src/main/kotlin/components/jni/libsignKey.dylib b/src/main/kotlin/components/jni/libsignKey.dylib index 2206eda..10be337 100755 Binary files a/src/main/kotlin/components/jni/libsignKey.dylib and b/src/main/kotlin/components/jni/libsignKey.dylib differ