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

com.likethesalad.placeholder.data.helpers.wrappers.AndroidExtensionWrapper.kt Maven / Gradle / Ivy

Go to download

This is a Gradle plugin for Android applications which resolves XML string references in other XML strings.

There is a newer version: 1.3.0
Show newest version
package com.likethesalad.placeholder.data.helpers.wrappers

import org.gradle.api.DomainObjectSet
import org.gradle.api.NamedDomainObjectContainer

class AndroidExtensionWrapper(private val androidExtension: Any) {

    private val clazz: Class<*> = androidExtension.javaClass
    private val getSourceSetsMethod by lazy { clazz.getMethod("getSourceSets") }
    private val getApplicationVariantsMethod by lazy { clazz.getMethod("getApplicationVariants") }

    fun getSourceSets(): Map {
        val generic = getSourceSetsMethod.invoke(androidExtension) as NamedDomainObjectContainer<*>
        return generic.map {
            AndroidSourceSetWrapper(it)
        }.map { it.getName() to it }.toMap()
    }

    fun getApplicationVariants(): Set {
        return (getApplicationVariantsMethod.invoke(androidExtension) as DomainObjectSet<*>).map {
            ApplicationVariantWrapper(it)
        }.toSet()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy