sh.christian.aaraar.gradle.agp.Agp8.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agp-compat-agp8 Show documentation
Show all versions of agp-compat-agp8 Show documentation
Compatibility layer for interacting with AGP 8.
package sh.christian.aaraar.gradle.agp
import com.android.build.api.attributes.BuildTypeAttr
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import org.gradle.api.Project
import org.gradle.api.attributes.AttributeContainer
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.named
/**
* Compatibility layer for using AGP 8 at runtime.
*/
class Agp8(private val project: Project) : AgpCompat {
private val androidComponents = project.extensions.getByType()
override val android: AndroidExtension =
Agp8AndroidExtension(project.extensions.getByType())
override fun AttributeContainer.buildTypeAttribute(buildType: String) {
attribute(BuildTypeAttr.ATTRIBUTE, project.objects.named(buildType))
}
override fun onVariants(callback: (AndroidVariant) -> Unit) {
return androidComponents.onVariants { callback(Agp8AndroidVariant(it)) }
}
}