com.autonomousapps.internal.android.BaseAndroidGradlePlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-analysis-gradle-plugin Show documentation
Show all versions of dependency-analysis-gradle-plugin Show documentation
Analyzes dependency usage in Android and JVM projects
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")
}
}