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

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

There is a newer version: 2.0.0-beta+94
Show newest version
package io.appmetrica.gradle.aarcheck.module

import io.appmetrica.gradle.aarcheck.AarCheckException
import io.appmetrica.gradle.aarcheck.AarCheckPlugin
import io.appmetrica.gradle.aarcheck.utils.DiffUtils
import org.slf4j.LoggerFactory
import java.io.File

object ModuleChecker {
    private val logger = LoggerFactory.getLogger(AarCheckPlugin.PLUGIN_NAME)

    fun check(dumpFile: File, moduleFile: File) {
        if (!dumpFile.exists()) {
            throw AarCheckException(
                "Module check failed. Not found file ${dumpFile.canonicalPath}. " +
                    "You can run :moduleDump task to generate module dump"
            )
        }

        val dump = dumpFile.readText()
        val module = moduleFile.readText()
        val diff = DiffUtils.diff(dump, ModuleNormalizer.normalize(module), "dump module", "cur module")
        if (diff != null) {
            logger.error("Diff:\n$diff")
            throw AarCheckException(
                "Module check failed. See diff above. " +
                    "You can run :moduleDump task to overwrite module dump"
            )
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy