Skip to content

Instantly share code, notes, and snippets.

@peacepassion
Last active August 15, 2016 08:09
Show Gist options
  • Save peacepassion/5a1a8088ed28ffb3c1a43b3f3393e350 to your computer and use it in GitHub Desktop.
Save peacepassion/5a1a8088ed28ffb3c1a43b3f3393e350 to your computer and use it in GitHub Desktop.
Way to get some important information of Android gradle plugin
project.android.applicationVariants.all { ApkVariant variant ->
println "variant class: ${variant.getClass()}"
ApplicationVariantImpl variant2 = (ApplicationVariantImpl) variant;
Field field = ApplicationVariantImpl.class.getDeclaredField("variantData")
field.setAccessible(true)
ApplicationVariantData data = field.get(variant2)
VariantScopeImpl scope = data.getScope();
field = BaseVariantData.class.getDeclaredField('taskManager')
field.setAccessible(true)
TaskManager taskManager = field.get(data)
println 'task manager: ' + taskManager
field = TaskManager.class.getDeclaredField('dependencyManager')
field.setAccessible(true)
DependencyManager dependencyManager = field.get(taskManager)
println 'dependency manager: ' + dependencyManager
println 'variant dependencies: ' + data.variantDependency
println 'variant dependencies library: ' + data.variantDependency.libraries
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment