From 6b551610dfe0503a312b14fd860b2758d7707b1c Mon Sep 17 00:00:00 2001 From: porokoro Date: Sun, 20 Mar 2016 00:17:26 +0100 Subject: Provide basic support for Android library projects and make the source directories configurable for the user --- .../src/main/kotlin/main.kt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 dokka-android-gradle-plugin/src/main/kotlin/main.kt (limited to 'dokka-android-gradle-plugin/src/main/kotlin/main.kt') diff --git a/dokka-android-gradle-plugin/src/main/kotlin/main.kt b/dokka-android-gradle-plugin/src/main/kotlin/main.kt new file mode 100644 index 00000000..9a92e2a2 --- /dev/null +++ b/dokka-android-gradle-plugin/src/main/kotlin/main.kt @@ -0,0 +1,38 @@ +package org.jetbrains.dokka.gradle + +import com.android.build.gradle.LibraryExtension +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.SourceSet +import java.io.File + +open class DokkaAndroidPlugin : Plugin { + override fun apply(project: Project) { + project.tasks.create("dokka", DokkaAndroidTask::class.java).apply { + moduleName = project.name + outputDirectory = File(project.buildDir, "dokka").absolutePath + } + } +} + +open class DokkaAndroidTask : DokkaTask() { + override val sdkProvider: SdkProvider? = AndroidSdkProvider(project) +} + +private class AndroidSdkProvider(private val project: Project) : SdkProvider { + private val ext by lazy { project.extensions.getByType(LibraryExtension::class.java) } + + override val name: String = "android" + + override val isValid: Boolean + get() = project.plugins.hasPlugin("com.android.library") + + override val classpath: List + get() = ext.bootClasspath + + override val sourceDirs: Set? + get() { + val sourceSet = ext.sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) + return sourceSet?.java?.srcDirs + } +} -- cgit