Skip to content

Instantly share code, notes, and snippets.

@Hackforid
Created August 19, 2019 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hackforid/fce754688668b3a6baaa10f80cf554f8 to your computer and use it in GitHub Desktop.
Save Hackforid/fce754688668b3a6baaa10f80cf554f8 to your computer and use it in GitHub Desktop.
ButterKnife-Reflection
import org.gradle.api.Plugin
import org.gradle.api.Project
class ButterKnifePlugin: Plugin<Project> {
private val KAPT_NAME = "kapt"
private val APT_NAME = "annotationProcessor"
private val KOTLIN_KAPT_PLUGIN_ID = "org.jetbrains.kotlin.kapt"
private val BUTTER_KNIFE_PLUGIN_ID = "com.jakewharton.butterknife"
override fun apply(project: Project) {
val useKapt = project.pluginManager.hasPlugin(KOTLIN_KAPT_PLUGIN_ID)
System.out.println("use kapt = $useKapt")
if (!project.pluginManager.hasPlugin(BUTTER_KNIFE_PLUGIN_ID)) {
project.pluginManager.apply(BUTTER_KNIFE_PLUGIN_ID)
}
// project.dependencies.add(if (useKapt) KAPT_NAME else APT_NAME, "com.jakewharton:butterknife-compiler:8.6.0")
// project.dependencies.add("implementation", "com.smile.gifshow.butterknife:butterknife:8.5.1.1")
// state.env.put("isModuleApp", gradle.rootProject.extensions.getByName("ext").properties.getOrDefault("isModuleApplication", false))
project.dependencies.add("implementation", "com.jakewharton:butterknife-reflect:9.0.0")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment