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

sh.christian.aaraar.gradle.agp.Agp8.kt Maven / Gradle / Ivy

There is a newer version: 0.0.17
Show newest version
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)) }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy