aboutsummaryrefslogtreecommitdiff
path: root/dokka-android-gradle-plugin/src/main/kotlin/main.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <intelliyole@gmail.com>2016-03-31 16:15:35 +0200
committerDmitry Jemerov <intelliyole@gmail.com>2016-03-31 16:15:35 +0200
commit3ed824ed77e87b09fc997189b74f1201e6e03b14 (patch)
treed2ec3d9a0889079bbf82b8ad82ea31dd69f59915 /dokka-android-gradle-plugin/src/main/kotlin/main.kt
parent6051ab5051be76d6c830a9996901bfbb9e1f901e (diff)
parent908aa606ea7c46346b590aaee79dd6cc1851e36d (diff)
downloaddokka-3ed824ed77e87b09fc997189b74f1201e6e03b14.tar.gz
dokka-3ed824ed77e87b09fc997189b74f1201e6e03b14.tar.bz2
dokka-3ed824ed77e87b09fc997189b74f1201e6e03b14.zip
Merge pull request #64 from porokoro/android-and-custom-sources
Android support and custom sources
Diffstat (limited to 'dokka-android-gradle-plugin/src/main/kotlin/main.kt')
-rw-r--r--dokka-android-gradle-plugin/src/main/kotlin/main.kt38
1 files changed, 38 insertions, 0 deletions
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<Project> {
+ 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<File>
+ get() = ext.bootClasspath
+
+ override val sourceDirs: Set<File>?
+ get() {
+ val sourceSet = ext.sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME)
+ return sourceSet?.java?.srcDirs
+ }
+}