aboutsummaryrefslogtreecommitdiff
path: root/runners/android-gradle-plugin/src/main
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-06-16 22:38:01 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-06-20 16:15:48 +0300
commit558c6b67fafb73c97db9ce1eeadfd4fcbb911134 (patch)
tree0c80684834dac2d178700055f11acb47aca51ffb /runners/android-gradle-plugin/src/main
parent7c55d94eeb42f851e5ee0664bb38a873b6c06ee1 (diff)
downloaddokka-558c6b67fafb73c97db9ce1eeadfd4fcbb911134.tar.gz
dokka-558c6b67fafb73c97db9ce1eeadfd4fcbb911134.tar.bz2
dokka-558c6b67fafb73c97db9ce1eeadfd4fcbb911134.zip
Configure dokka based on Kotlin compile tasks
Diffstat (limited to 'runners/android-gradle-plugin/src/main')
-rw-r--r--runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt53
1 files changed, 1 insertions, 52 deletions
diff --git a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
index 5db2ad2f..8dd0a4c6 100644
--- a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
+++ b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
@@ -1,13 +1,8 @@
package org.jetbrains.dokka.gradle
-import com.android.build.gradle.*
-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> {
override fun apply(project: Project) {
@@ -19,50 +14,4 @@ open class DokkaAndroidPlugin : Plugin<Project> {
}
}
-open class DokkaAndroidTask : DokkaTask() {
- override val sdkProvider: SdkProvider? = AndroidSdkProvider(project)
-}
-
-private class AndroidSdkProvider(private val project: Project) : SdkProvider {
- private val ext: BaseExtension? by lazy {
- project.extensions.findByType(LibraryExtension::class.java)
- ?: project.extensions.findByType(AppExtension::class.java)
- ?: project.extensions.findByType(TestExtension::class.java)
- }
-
- private val isAndroidProject: Boolean get() = ext != null
-
- private val variantManager: VariantManager? by lazy {
- val plugin = (project.plugins.findPlugin("android")
- ?: project.plugins.findPlugin("android-library")
- ?: project.plugins.findPlugin("com.android.test")
- ?: throw Exception("Android plugin not found, please use dokka-android with android or android-library plugin.")) as BasePlugin
- plugin.javaClass.kotlin.memberProperties
- .find { it.name == "variantManager" }
- ?.apply { isAccessible = true }
- ?.let { it.get(plugin) as VariantManager }
- ?: plugin.variantManager
- }
-
- private val allVariantsClassPath by lazy {
- try {
- variantManager?.variantDataList?.flatMap { it.variantConfiguration.compileClasspath }!!
- } catch(e: Exception) {
- throw Exception("Unsupported version of android build tools, could not access variant manager.", e)
- }
- }
-
- override val name: String = "android"
-
- override val isValid: Boolean
- get() = isAndroidProject
-
- override val classpath: List<File>
- get() = ext?.bootClasspath.orEmpty() + allVariantsClassPath
-
- override val sourceDirs: Set<File>?
- get() {
- val sourceSet = ext?.sourceSets?.findByName(SourceSet.MAIN_SOURCE_SET_NAME)
- return sourceSet?.java?.srcDirs
- }
-}
+open class DokkaAndroidTask : DokkaTask()