To install the latest version, add the following to the lib/bld/bld-wrapper.properties file:
bld.extension-dokka=com.uwyn.rife2:bld-dokkaFor more information, please refer to the extensions documentation.
To generate a project's documentation in various formats. The examples below use
fromProject,
loggingLevel,
outputDir,
outputFormat,
failOnWarning, and
execute:
import java.io.File;
import rife.bld.extension.DokkaOperation;
import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat;
import rife.bld.extension.tools.IOTools;
...
@BuildCommand(value = "dokka-gfm", summary = "Generates documentation in GitHub flavored markdown format")
public void dokkaGfm() throws ExitStatusException, IOException, InterruptedException {
new DokkaOperation()
.fromProject(this)
.loggingLevel(LoggingLevel.INFO)
// Create build/dokka/gfm
.outputDir(IOTools.resolveFile(buildDirectory(), "dokka", "gfm"))
.outputFormat(OutputFormat.MARKDOWN) // required
.execute();
}
@BuildCommand(value = "dokka-html", summary = "Generates documentation in HTML format")
public void dokkaHtml() throws ExitStatusException, IOException, InterruptedException {
new DokkaOperation()
.fromProject(this) // required
.loggingLevel(LoggingLevel.INFO)
// Create build/dokka/html
.outputDir(IOTools.resolveFile(buildDirectory(), "dokka", "html"))
.outputFormat(OutputFormat.HTML) // required
.execute();
}
@BuildCommand(value = "dokka-jekyll", summary = "Generates documentation in Jekyll flavored markdown format")
public void dokkaJekyll() throws ExitStatusException, IOException, InterruptedException {
new DokkaOperation()
.fromProject(this) // required
.loggingLevel(LoggingLevel.INFO)
// Create build/dokka/jekyll
.outputDir(IOTools.resolveFile(buildDirectory(), "dokka", "jekyll"))
.outputFormat(OutputFormat.JEKYLL) // required
.execute();
}
@BuildCommand(summary = "Generates Javadoc for the project")
@Override
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
new DokkaOperation()
.fromProject(this) // required
.failOnWarning(true)
.loggingLevel(LoggingLevel.INFO)
// Create build/javadoc
.outputDir(new File(buildDirectory(), "javadoc"))
.outputFormat(OutputFormat.JAVADOC) // required
.execute();
}./bld javadoc
./bld dokka-html
./bld dokka-gfm
./bld dokka-jekyllfromProject seeds the source set with src/main/kotlin, plus the project's compile and provided classpath jars, the project's javaRelease (as the source set's JDK version), and the project name as the module name. Projects with sources elsewhere — for example mixed Java/Kotlin, generated sources, or extra source roots — must extend the source set themselves.
Call fromProject first so the defaults and classpath are populated, then add sources with sourceSet(Consumer<SourceSet):
new DokkaOperation()
.fromProject(this) // seeds src/main/kotlin, classpath, jdkVersion, moduleName
.sourceSet(ss -> ss
.src(new File("src/main/java")) // mixed Java/Kotlin
.src(new File("src/generated/kotlin")))
.outputFormat(OutputFormat.JAVADOC)
.outputDir(new File(buildDirectory(), "javadoc"))
.execute();For a fully custom source set (no src/main/kotlin, no project classpath), pass a configured SourceSet to sourceSet(SourceSet) before calling fromProject — fromProject only adds defaults when the source set is empty, so anything you set first is preserved.
By default, the extension downloads the version defined by the
DOKKA_VERSION
constant.
You can override this to target a specific Dokka release with the version(String) method
(or version(Version)):
new DokkaOperation()
.fromProject(this)
.version("2.1.0") // String form
// .version(new VersionNumber(2, 1, 0)) // Version form
.loggingLevel(LoggingLevel.INFO)
.outputDir(new File(buildDirectory(), "javadoc"))
.outputFormat(OutputFormat.JAVADOC)
.execute();Warning: Only Dokka
2.xreleases are supported.
The following are commonly used but not shown in the main examples; see the API Reference for the full list.
json(...)— supply a Dokka JSON configuration file instead of (or alongside) the fluent options.offlineMode(boolean)— resolve remote links/packages from local caches only.failOnWarning(boolean)— fail the build if Dokka emits a warning or error (used in thejavadocexample above).pluginConfigurations(String, String)/pluginsClasspath(File...)— configure Dokka plugins and the jars they need.
There is also a Kotlin Template Project with support for Dokka and the Detekt extensions.
Please check the Dokka Operation documentation for all available configuration options.