Skip to content

Commit

Permalink
Merge branch 'remove-jackson-parser' into 'master'
Browse files Browse the repository at this point in the history
Remove Jackson from app-sizer to prevent lib conflict

See merge request mobile/pax-app-core/app-sizer!43
  • Loading branch information
vanminh-grabtaxi committed Sep 28, 2024
2 parents 86c3685 + b354c83 commit 6be1ece
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
3 changes: 1 addition & 2 deletions app-sizer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ dependencies {
implementation libs.org.influxdb.client
implementation libs.org.smali.dexlib2
implementation libs.android.tools.apkanalyzer
implementation libs.jackson.module.kotlin
implementation libs.jackson.dataformat.yaml
implementation libs.guava
implementation libs.google.dagger
implementation libs.gson

kapt libs.dagger.compiler

testImplementation libs.kotlin.test
testImplementation libs.android.tools.bundletool
testImplementation libs.android.tools.common
Expand Down
42 changes: 20 additions & 22 deletions app-sizer/src/main/kotlin/com/grab/sizer/analyzer/TeamMapping.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
*/

package com.grab.sizer.analyzer

import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.Constructor
import org.yaml.snakeyaml.nodes.MappingNode
import org.yaml.snakeyaml.nodes.Node
import org.yaml.snakeyaml.nodes.NodeTuple
import org.yaml.snakeyaml.nodes.ScalarNode
import org.yaml.snakeyaml.LoaderOptions
import java.io.File


Expand All @@ -52,7 +44,6 @@ class DummyTeamMapping : TeamMapping {
}



class YmlTeamMapping(
private val ymlFile: File
) : TeamMapping {
Expand All @@ -71,20 +62,27 @@ class YmlTeamMapping(
}

private fun loadTeamToModuleMap(): Map<String, List<String>> {
val loaderOptions = LoaderOptions()
val constructor = object : Constructor(loaderOptions) {
override fun constructMapping(node: MappingNode?): MutableMap<Any?, Any?> {
val map = super.constructMapping(node)
return map.mapValues { (_, value) ->
when (value) {
null -> emptyList<String>()
is List<*> -> value
else -> listOf(value.toString())
val lines = ymlFile.readLines()
val result = mutableMapOf<String, MutableList<String>>()
var currentTeam: String? = null

for (line in lines) {
val trimmedLine = line.trim()
when {
trimmedLine.isEmpty() || trimmedLine.startsWith("#") -> continue // Skip empty lines and comments
trimmedLine.endsWith(":") -> {
currentTeam = trimmedLine.dropLast(1)
result[currentTeam] = mutableListOf()
}
trimmedLine.startsWith("- ") -> {
currentTeam?.let {
result[it]?.add(trimmedLine.removePrefix("- ").trim())
}
}.toMutableMap()
}
}
}
val yaml = Yaml(constructor)
return yaml.load(ymlFile.inputStream())

return result
}
}

}
7 changes: 3 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ clikt = "4.4.0"
bundletool = "1.14.1"
apkanalyzer = "31.5.1"
common = "31.5.1"
jackson-module-kotlin = "2.17.2"
jackson-dataformat-yaml = "2.17.2"
jackson = "2.15.0"
guava = "33.2.1-jre"
gson = "2.10.1"
influxdbClient = "2.24"
Expand All @@ -31,8 +30,8 @@ clikt = { module = "com.github.ajalt.clikt:clikt", version.ref = "clikt" }
android-tools-bundletool = { module = "com.android.tools.build:bundletool", version.ref = "bundletool" }
android-tools-apkanalyzer = { module = "com.android.tools.apkparser:apkanalyzer", version.ref = "apkanalyzer" }
android-tools-common = { module = "com.android.tools:common", version.ref = "common" }
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson-module-kotlin" }
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson-dataformat-yaml" }
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
org-influxdb-client = { module = "org.influxdb:influxdb-java", version.ref = "influxdbClient" }
Expand Down
2 changes: 1 addition & 1 deletion sample/module-owner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Platform:
Team1:
- android-module-level1
Team2:
- :sample-group:android-module-level2
- sample-group:android-module-level2
- kotlin-module

0 comments on commit 6be1ece

Please sign in to comment.