Kotlin Help

Get started with Dokka

Below you can find simple instructions to help you get started with Dokka.

Apply the Gradle Dokka plugin

Apply the Dokka Gradle plugin (DGP) in the root build script of your project:

plugins { id("org.jetbrains.dokka") version "2.1.0" }

Document multi-project builds

When documenting multi-project builds, apply the plugin to every subproject you want to document. Share Dokka configuration across subprojects by using one of the following approaches:

  • Convention plugin

  • Direct configuration in each subproject if you’re not using convention plugins

For more information about sharing Dokka configuration in multi-project builds, see Multi-project configuration.

Generate documentation

To generate documentation, run the following Gradle task:

./gradlew :dokkaGenerate

This task works for both single and multi-project builds.

Run the dokkaGenerate task from the aggregating project by prefixing the task with its project path (:). For example:

./gradlew :dokkaGenerate // OR ./gradlew :aggregatingProject:dokkaGenerate

Avoid running ./gradlew dokkaGenerate instead of ./gradlew :dokkaGenerate or ./gradlew :aggregatingProject:dokkaGenerate. Without a project path (:) prefixing the task, Gradle tries to run all dokkaGenerate tasks across the entire build, which may trigger unnecessary work.

You can use different tasks to generate output in HTML, Javadoc or both HTML and Javadoc.

Apply the Gradle Dokka plugin

Apply the Gradle plugin for Dokka in the root build script of your project:

plugins { id 'org.jetbrains.dokka' version '2.1.0' }

Document multi-project builds

When documenting multi-project builds, you need to apply the plugin to every subproject you want to document. Share Dokka configuration across subprojects by using one of the following approaches:

  • Convention plugin

  • Direct configuration in each subproject if you’re not using convention plugins

For more information about sharing Dokka configuration in multi-project builds, see Multi-project configuration.

Generate documentation

To generate documentation, run the following Gradle task:

./gradlew :dokkaGenerate

This task works for both single and multi-project builds.

Run the dokkaGenerate task from the aggregating project by prefixing the task with its project path. For example:

./gradlew :dokkaGenerate // OR ./gradlew :aggregatingProject:dokkaGenerate

Avoid running ./gradlew dokkaGenerate instead of ./gradlew :dokkaGenerate or ./gradlew :aggregatingProject:dokkaGenerate. Without a project path (:) prefixing the task, Gradle tries to run all dokkaGenerate tasks across the entire build, which may trigger unnecessary work.

You can use different tasks to generate output in HTML, Javadoc or both HTML and Javadoc.

Add the Maven plugin for Dokka to the plugins section of your POM file:

<build> <plugins> <plugin> <groupId>org.jetbrains.dokka</groupId> <artifactId>dokka-maven-plugin</artifactId> <version>2.1.0</version> <executions> <execution> <phase>pre-site</phase> <goals> <goal>dokka</goal> </goals> </execution> </executions> </plugin> </plugins> </build>

To generate documentation, run the dokka:dokka goal.

By default, the output directory is set to target/dokka.

To learn more about using Dokka with Maven, see Maven.

18 December 2025