Skip to content Skip to sidebar Skip to footer

How Do You Publish KDoc For A Kotlin Library Using Maven On Jitpack?

Background After a lot of researching and trying out, and also asking for help, I've succeeded publishing a private Github repository using maven on Jitpack (written here). So, cur

Solution 1:

You need to use Dokka for auto documenting Kotlin project. You can find a brief explanation of Dokka on this article and also read the documentation if required.

Using the Gradle plugin

The preferred way is to use plugins block.

build.gradle.kts:

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

repositories {
    mavenCentral() }

The plugin adds dokkaHtml, dokkaJavadoc, dokkaGfm and dokkaJekyll tasks to the project.

Applying plugins

Dokka plugin creates Gradle configuration for each output format in the form of dokka${format}Plugin:

dependencies {
    dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.4.32") }

You can also create a custom Dokka task and add plugins directly inside:

val customDokkaTask by creating(DokkaTask::class) {
    dependencies {
        plugins("org.jetbrains.dokka:kotlin-as-java-plugin:1.4.32")
    } }

Please note that dokkaJavadoc task will properly document only single jvm source set

To generate the documentation, use the appropriate dokka${format} Gradle task:

./gradlew dokkaHtml

Please see the Dokka Gradle example project for an example.

Make sure you apply Dokka after com.android.library and kotlin-android.

buildscript {
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
        classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
    } } repositories {
    mavenCentral() } apply(plugin= "com.android.library") apply(plugin= "kotlin-android") apply(plugin= "org.jetbrains.dokka")

dokkaHtml.configure {
    dokkaSourceSets {
        named("main") {
            noAndroidSdkLink.set(false)
        }   
    } }

More at official GitHub repo - https://github.com/Kotlin/dokka You may like this article as well.


Post a Comment for "How Do You Publish KDoc For A Kotlin Library Using Maven On Jitpack?"