All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.appmetrica.gradle.aarcheck.module.ModuleNormalizer.kt Maven / Gradle / Ivy

The newest version!
package io.appmetrica.gradle.aarcheck.module

import groovy.json.JsonBuilder
import groovy.json.JsonSlurper

object ModuleNormalizer {
    fun normalize(module: String): String {
        val json = JsonSlurper().parseText(module) as Map<*, *>
        json.getMap("createdBy").getMap("gradle")["buildId"] = ""
        json.getList("variants").forEach { variant ->
            variant.getList("files").forEach { file ->
                file["size"] = -1
                file["sha512"] = ""
                file["sha256"] = ""
                file["sha1"] = ""
                file["md5"] = ""
            }
        }
        return JsonBuilder(json).toPrettyString() + "\n"
    }

    @Suppress("UNCHECKED_CAST")
    private fun Map<*, *>.getMap(key: String): MutableMap =
        this[key] as MutableMap

    @Suppress("UNCHECKED_CAST")
    private fun Map<*, *>.getList(key: String): List> =
        this[key] as List>
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy