diff options
author | Simon Ogorodnik <sem-oro@yandex.ru> | 2016-11-11 15:34:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-11 15:34:42 +0300 |
commit | d8be364a89ab7d9f38196ef17d0d4eb1d9659b48 (patch) | |
tree | 461fbe19f8913f7b4f1fb1da52a30820be2a7da1 /runners/android-gradle-plugin | |
parent | 32cfff6d3dcb099e891e56b969c3c561d8fd9769 (diff) | |
parent | 4dc2f010ae28bb4142504bf7238fc4a33f1f1eb8 (diff) | |
download | dokka-d8be364a89ab7d9f38196ef17d0d4eb1d9659b48.tar.gz dokka-d8be364a89ab7d9f38196ef17d0d4eb1d9659b48.tar.bz2 dokka-d8be364a89ab7d9f38196ef17d0d4eb1d9659b48.zip |
Fixed android-gradle-plugin crash with android gradle build tools 2.2.0
Diffstat (limited to 'runners/android-gradle-plugin')
-rw-r--r-- | runners/android-gradle-plugin/build.gradle | 11 | ||||
-rw-r--r-- | runners/android-gradle-plugin/src/main/kotlin/main.kt | 14 |
2 files changed, 17 insertions, 8 deletions
diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle index dd6f2e3d..6e8da695 100644 --- a/runners/android-gradle-plugin/build.gradle +++ b/runners/android-gradle-plugin/build.gradle @@ -2,11 +2,6 @@ apply plugin: 'java' sourceCompatibility = 1.6 -task wrapper(type: Wrapper) { - gradleVersion = '2.5' - distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" -} - apply plugin: 'com.github.johnrengelman.shadow' configurations { @@ -18,6 +13,10 @@ tasks.withType(AbstractCompile) { classpath += configurations.shadow } +repositories { + jcenter() +} + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' shadow project(':runners:fatjar') @@ -26,7 +25,7 @@ dependencies { provided gradleApi() provided localGroovy() - shadow 'com.android.tools.build:gradle:2.0.0' + shadow 'com.android.tools.build:gradle:2.2.0' } task sourceJar(type: Jar) { 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<Project> { val allVariantsClassPath = mutableSetOf<File>() @@ -32,8 +36,14 @@ open class DokkaAndroidPlugin : Plugin<Project> { } 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 } } } |