Skip to content

Commit 7a1ae4f

Browse files
authored
Merge pull request #6 from StringCare/develop
Develop
2 parents 57c0428 + bdf07dd commit 7a1ae4f

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group 'com.stringcare'
9-
version '3.4'
9+
version '3.5'
1010

1111
def siteUrl = 'https://github.com/StringCare/KotlinGradlePlugin'
1212
def gitUrl = 'https://github.com/StringCare/KotlinGradlePlugin.git'

src/main/kotlin/StringCare.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ open class StringCare : Plugin<Project> {
2525
@JvmStatic
2626
internal val moduleMap: MutableMap<String, Configuration> = mutableMapOf()
2727

28+
@JvmStatic
29+
internal val variantMap: MutableMap<String, VariantApplicationId> = mutableMapOf()
30+
2831
@JvmStatic
2932
internal var mainModule: String = defaultMainModule
3033

@@ -63,6 +66,13 @@ open class StringCare : Plugin<Project> {
6366
moduleMap[module.name]!!.stringFiles.addAll(defaultConfig().stringFiles)
6467
}
6568
}
69+
extension.variants.forEach { variant ->
70+
variantMap[variant.name] = VariantApplicationId(variant.name).apply {
71+
applicationId = variant.applicationId
72+
mockedFingerprint = variant.mockedFingerprint
73+
skip = variant.skip
74+
}
75+
}
6676
this.project.registerTask()
6777
}
6878
this.project.gradle.addBuildListener(ExecutionListener(
@@ -71,7 +81,7 @@ open class StringCare : Plugin<Project> {
7181
// nothing to do here
7282
},
7383
mergeResourcesStart = { module, variant ->
74-
fingerPrint(module, variant, extension.debug) { key ->
84+
fingerPrint(variantMap, module, variant, extension.debug) { key ->
7585
if ("none" == key) {
7686
return@fingerPrint
7787
}
@@ -130,7 +140,7 @@ open class StringCare : Plugin<Project> {
130140
restoreResourceFiles(absoluteProjectPath, module)
131141
},
132142
mergeAssetsStart = { module, variant ->
133-
fingerPrint(module, variant, extension.debug) { key ->
143+
fingerPrint(variantMap, module, variant, extension.debug) { key ->
134144
if ("none" == key) {
135145
return@fingerPrint
136146
}
@@ -213,6 +223,7 @@ open class StringCare : Plugin<Project> {
213223

214224
open class VariantApplicationId(var name: String) {
215225
var applicationId = ""
226+
var mockedFingerprint = ""
216227
var skip = false
217228
}
218229

src/main/kotlin/components/Fingerprint.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ private class Fingerprint {
7575
/**
7676
* Gets the signing report trace and extracts the fingerprint
7777
*/
78-
fun fingerPrint(module: String, variant: String, debug: Boolean, keyFound: (key: String) -> Unit) {
78+
fun fingerPrint(variantMap: MutableMap<String, StringCare.VariantApplicationId>, module: String, variant: String, debug: Boolean, keyFound: (key: String) -> Unit) {
79+
if (variantMap.containsKey(variant)) {
80+
if (variantMap[variant]!!.mockedFingerprint.isNotEmpty()) {
81+
keyFound(variantMap[variant]!!.mockedFingerprint)
82+
return
83+
}
84+
}
7985
signingReportTask().runCommand { _, report ->
8086
keyFound(report.extractFingerprint(module, variant, debug))
8187
}

src/main/kotlin/components/Vars.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package components
22

33
import java.io.File
44

5-
internal const val version = "3.3"
5+
internal const val version = "3.5"
66
internal const val testProjectName = "KotlinSample"
77
internal const val defaultDebug = false
88
internal const val defaultMainModule = "app"
33.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)