From 4dc2f010ae28bb4142504bf7238fc4a33f1f1eb8 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 10 Nov 2016 21:54:15 +0300 Subject: Fixed android-gradle-plugin crash with android gradle build tools 2.2.0. Updated gradle wrapper to 2.14.1 to compile with gradle build tools 2.2.0 --- runners/android-gradle-plugin/src/main/kotlin/main.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'runners/android-gradle-plugin/src/main') diff --git a/runners/android-gradle-plugin/src/main/kotlin/main.kt b/runners/android-gradle-plugin/src/main/kotlin/main.kt index 054ed358..11040b2a 100644 --- a/runners/android-gradle-plugin/src/main/kotlin/main.kt +++ b/runners/android-gradle-plugin/src/main/kotlin/main.kt @@ -1,12 +1,16 @@ package org.jetbrains.dokka.gradle import com.android.build.gradle.AppExtension +import com.android.build.gradle.BasePlugin import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant +import com.android.build.gradle.internal.VariantManager import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.SourceSet import java.io.File +import kotlin.reflect.jvm.isAccessible +import kotlin.reflect.memberProperties open class DokkaAndroidPlugin : Plugin { val allVariantsClassPath = mutableSetOf() @@ -32,8 +36,14 @@ open class DokkaAndroidPlugin : Plugin { } private fun collectClasspath(project: Project) { - val variants = project.collectAllVariants() - variants.flatMapTo(allVariantsClassPath) { it.javaCompiler.classpath.files } + val plugin = (project.plugins.findPlugin("android") + ?: project.plugins.findPlugin("android-library") + ?: project.plugins.findPlugin("com.android.test")) as BasePlugin + + val variantManagerProperty = plugin::class.memberProperties.find { it.name == "variantManager" }!! + variantManagerProperty.isAccessible = true + val variantManager = variantManagerProperty.get(plugin) as VariantManager + variantManager.variantDataList.flatMapTo(allVariantsClassPath) { it.variantConfiguration.compileClasspath } } } -- cgit