net.twisterrob.gradle.common.BaseQualityPlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of twister-quality-common Show documentation
Show all versions of twister-quality-common Show documentation
Shared classes between checkers. (Not to be consumed directly.)
package net.twisterrob.gradle.common
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.tasks.SourceTask
open class BaseQualityPlugin(
private val taskCreatorType: Class>,
private val extensionName: String,
private val extensionType: Class>
) : BaseExposedPlugin() {
override fun apply(target: Project) {
super.apply(target)
val quality = project.extensions.findByName("quality") as ExtensionAware?
?: project.extensions.create("quality", FakeQualityExtension::class.java) as ExtensionAware
quality.extensions.create(extensionName, extensionType, project)
// level of indirection with base is to prevent loading classes in project not having Android
project.plugins.withId("com.android.base") {
val taskCreator = taskCreatorType.newInstance(project)
AndroidVariantApplier(project).applyVariants(taskCreator::applyTo)
}
}
}
private inline fun Class.newInstance(p1: P1?): T =
this.getDeclaredConstructor(P1::class.java).newInstance(p1)
private open class FakeQualityExtension
© 2015 - 2025 Weber Informatics LLC | Privacy Policy