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

com.autonomousapps.internal.android.BaseAndroidGradlePlugin.kt Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.autonomousapps.internal.android

import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.Task
import java.lang.reflect.Method

internal abstract class BaseAndroidGradlePlugin(
  protected val project: Project,
  protected val agpVersion: String
) : AndroidGradlePlugin {

  protected abstract val bundleTaskType: String
  protected abstract val bundleTaskOutputMethodName: String

  @Suppress("UNCHECKED_CAST")
  protected fun getBundleTaskType(): Class = try {
    Class.forName(bundleTaskType) as Class
  } catch (e: ClassNotFoundException) {
    throw GradleException("Cannot find bundle class for AGP $agpVersion")
  }

  protected fun getOutputMethod(type: Class): Method = try {
    type.getDeclaredMethod(bundleTaskOutputMethodName)
  } catch (e: NoSuchMethodException) {
    throw GradleException("Cannot find output method name for AGP $agpVersion")
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy