com.likethesalad.placeholder.data.helpers.wrappers.AndroidExtensionWrapper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of string-reference Show documentation
Show all versions of string-reference Show documentation
This is a Gradle plugin for Android applications which resolves XML string references in other XML strings.
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()
}
}