aboutsummaryrefslogtreecommitdiff
path: root/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts
blob: 7fb7c115422bb875b94dc42ca11a35ea7490de5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import org.jetbrains.dokka.DokkaConfiguration.Visibility
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.net.URL

plugins {
    kotlin("jvm")
    id("org.jetbrains.dokka")
}

// You can apply and configure Dokka in each subproject
// individially or configure all subprojects at once
subprojects {
    apply(plugin = "org.jetbrains.dokka")

    tasks.withType<DokkaTaskPartial>().configureEach {
        dokkaSourceSets.configureEach {
            documentedVisibilities.set(setOf(
                Visibility.PUBLIC,
                Visibility.PROTECTED
            ))

            // In multi-project builds, `remoteUrl` must point to that project's dir specifically, so if you
            // want to configure sourceLinks at once in `subprojects {}`, you have to find the relative path.
            // Alternatively, you can move this configuration up into subproject build scripts,
            // and just hardcode the exact paths as demonstrated in the basic dokka-gradle-example.
            //
            // Read docs for more details: https://kotlinlang.org/docs/dokka-gradle.html#source-link-configuration
            sourceLink {
                val exampleDir = "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-multimodule-example"
                val projectRelativePath = rootProject.projectDir.toPath().relativize(projectDir.toPath())

                localDirectory.set(projectDir.resolve("src"))
                remoteUrl.set(URL("$exampleDir/$projectRelativePath/src"))
                remoteLineSuffix.set("#L")
            }
        }
    }
}

// Configures only the parent MultiModule task,
// this will not affect subprojects
tasks.dokkaHtmlMultiModule {
    moduleName.set("Dokka MultiModule Example")
}