aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runners/android-gradle-plugin/build.gradle2
-rw-r--r--runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt25
2 files changed, 20 insertions, 7 deletions
diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle
index e93add83..53bff935 100644
--- a/runners/android-gradle-plugin/build.gradle
+++ b/runners/android-gradle-plugin/build.gradle
@@ -27,7 +27,7 @@ dependencies {
provided gradleApi()
provided localGroovy()
- provided 'com.android.tools.build:gradle:2.2.0'
+ provided 'com.android.tools.build:gradle:2.3.0'
}
task sourceJar(type: Jar) {
diff --git a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
index 3c1e2284..63168e7b 100644
--- a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
+++ b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
@@ -37,15 +37,28 @@ open class DokkaAndroidPlugin : Plugin<Project> {
}
}
+
+ private fun getVariantManagerOld(plugin: BasePlugin): VariantManager? {
+ val variantManagerProperty =
+ plugin.javaClass.kotlin.memberProperties
+ .find { it.name == "variantManager" } ?: return null
+ variantManagerProperty.isAccessible = true
+ return variantManagerProperty.get(plugin) as VariantManager
+ }
+
+ private fun getVariantManager(plugin: BasePlugin): VariantManager = plugin.variantManager
+
private fun collectClasspath(project: Project) {
val plugin = (project.plugins.findPlugin("android")
?: project.plugins.findPlugin("android-library")
- ?: project.plugins.findPlugin("com.android.test")) as BasePlugin
-
- val variantManagerProperty = plugin.javaClass.kotlin.memberProperties.find { it.name == "variantManager" }!!
- variantManagerProperty.isAccessible = true
- val variantManager = variantManagerProperty.get(plugin) as VariantManager
- variantManager.variantDataList.flatMapTo(allVariantsClassPath) { it.variantConfiguration.compileClasspath }
+ ?: project.plugins.findPlugin("com.android.test")
+ ?: throw Exception("Android plugin not found, please use dokka-android with android or android-library plugin.")) as BasePlugin
+ try {
+ val variantManager = getVariantManagerOld(plugin) ?: getVariantManager(plugin)
+ variantManager.variantDataList.flatMapTo(allVariantsClassPath) { it.variantConfiguration.compileClasspath }
+ } catch(e: Exception) {
+ throw Exception("Unsupported version of android build tools, could not access variant manager.", e)
+ }
}
}