• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.jetbrains.dokka.gradle
2 
3 import org.gradle.api.Plugin
4 import org.gradle.api.Project
5 import org.gradle.api.tasks.Input
6 import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder
7 import java.io.File
8 
9 open class DokkaAndroidPlugin : Plugin<Project> {
applynull10     override fun apply(project: Project) {
11         DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka-android.properties"))
12         project.tasks.create("dokka", DokkaAndroidTask::class.java).apply {
13             moduleName = project.name
14             outputDirectory = File(project.buildDir, "dokka").absolutePath
15         }
16     }
17 }
18 
19 private val ANDROID_REFERENCE_URL = Builder("https://developer.android.com/reference/").build()
20 
21 open class DokkaAndroidTask : DokkaTask() {
22 
23     @Input var noAndroidSdkLink: Boolean = false
24 
collectSuppressedFilesnull25     override fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> {
26         val generatedRoot = project.buildDir.resolve("generated").absoluteFile
27         return sourceRoots
28             .map { File(it.path) }
29             .filter { it.startsWith(generatedRoot) }
30             .flatMap { it.walk().toList() }
31             .map { it.absolutePath }
32     }
33 
34     init {
<lambda>null35         project.afterEvaluate {
36             if (!noAndroidSdkLink) externalDocumentationLinks.add(ANDROID_REFERENCE_URL)
37         }
38     }
39 }
40