diff options
author | knize <kirill.knize@gmail.com> | 2017-03-31 01:53:53 +0300 |
---|---|---|
committer | knize <kirill.knize@gmail.com> | 2017-03-31 01:53:53 +0300 |
commit | 60f72380b49ed04734a10a99aac080f3483ee71b (patch) | |
tree | 9f04a8d920bb9e21b113a3cf62cb105eb102b760 /runners/android-gradle-plugin/src/main/kotlin | |
parent | dd0e4af1a4a6c638ecdc0d29f9abb7b77641a136 (diff) | |
download | dokka-60f72380b49ed04734a10a99aac080f3483ee71b.tar.gz dokka-60f72380b49ed04734a10a99aac080f3483ee71b.tar.bz2 dokka-60f72380b49ed04734a10a99aac080f3483ee71b.zip |
Fix dokka-android to support new build tools
Support getting variantManager after android
build tools 2.3.0 API changes
Fix for issue #140
Diffstat (limited to 'runners/android-gradle-plugin/src/main/kotlin')
-rw-r--r-- | runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt | 25 |
1 files changed, 19 insertions, 6 deletions
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) + } } } |