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

com.xml.guard.tasks.StringFogTask.kt Maven / Gradle / Ivy

package com.xml.guard.tasks

import com.xml.guard.entensions.GuardExtension
import com.xml.guard.model.MappingParser
import com.xml.guard.utils.allDependencyAndroidProjects
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject

open class StringFogTask @Inject constructor(
    private val guardExtension: GuardExtension,
    private val variantName: String,
) : DefaultTask() {

    init {
        group = "guard"
    }

    private val mappingFile by lazy { project.file(MappingParser.MAPPING_STRING_FOR) }
    private val mapping by lazy {
        MappingParser.parseStringFog(
            project,
            guardExtension,
            mappingFile,
            isSelfParse = true
        )
    }

    @TaskAction
    fun execute() {
        val androidProjects = allDependencyAndroidProjects(project)

        // 1、字符串混淆
        androidProjects.forEach { project ->
            mapping.fogAllStrings(project, variantName)
        }

        // 2、混淆映射写出到文件
        mapping.writeMappingToFile(mappingFile)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy