Home > Software engineering >  How to modify build.gradle.kts sourceSets for Dokka task?
How to modify build.gradle.kts sourceSets for Dokka task?

Time:09-07

I am using the Dokka plugin in build.gradle.kts. I am able to generate the Dokka HTML for my source code but have been unable to figure out how to configure the task to include package.md files that document packages. (I am not using modules.)

I tried this:

tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
    dokkaSourceSets {
        named("main") {
            includes.from("package.md")
        }
    }
}

I received an error because there was no package.md file in the root directory.

I also tried this line, but the wildcards were not expanded:

includes.from("src/**/package.md")

How do I instruct Gradle to include all files named package.md, regardless of their directory, the way it includes all Kotlin source code, regardless of directory?

This differs from How to configure Dokka for package documentation using Gradle?, which uses Groovy.

CodePudding user response:

I received an answer on the Kotlin Slack:

tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
    dokkaSourceSets {
        named("main") {
            includes.from(fileTree(project.rootDir) {
                include("src/**/package.md")
            })
        }
    }
}
  • Related