Hi folks, im trying to publish my library with jav...
# dokka
g
Hi folks, im trying to publish my library with javadocs included using dokka but when i am consuming it the docs do not seem to there (gradle.build.kts in thread). Thanks in advance for any help :)
In buildSrc: Publish.Kt
Copy code
fun Project.configureSdkPublication() {
    if (!isSdk) return

    plugins.withId("maven-publish") {
        extensions.configure<PublishingExtension> {
            repositories {
                configureMavenPublication(this@repositories)
            }
            // check for dokka
            if (plugins.findPlugin("org.jetbrains.dokka") != null) {
                val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") {
                    dependsOn(tasks["dokkaJavadoc"])
                    from(tasks["dokkaJavadoc"].outputs)
                    archiveClassifier.set("javadoc")
                }
                val dokkaHtmlJar by tasks.register<Jar>("dokkaHtmlJar") {
                    dependsOn(tasks["dokkaHtml"])
                    from(tasks["dokkaHtml"].outputs)
                    archiveClassifier.set("html-doc")
                }
                publications {
                    create<MavenPublication>("maven") {
                        pom {
                            configureMavenCentralMetadata(this@configureSdkPublication)
                        }
                        from(components["java"])
                        artifact(dokkaJavadocJar)
                        artifact(dokkaHtmlJar)
                    }
                }
            } else {
                val sourcesJar by tasks.registering(org.gradle.api.tasks.bundling.Jar::class) {
                    archiveClassifier.set("sources")
                }
                publications {
                    create<MavenPublication>("maven") {
                        pom {
                            configureMavenCentralMetadata(this@configureSdkPublication)
                        }
                        from(components["java"])
                        artifact(sourcesJar.get())
                    }
                }
            }
        }
    }
}
Info: calling it in 3 of my modules, which two of them will have kdocs. Module gradle.build example:
Copy code
plugins {
    kotlin("jvm")
    kotlin("plugin.serialization")
    `maven-publish`
    `java-library`
    id("org.jetbrains.dokka")
}

val kotlinxCoroutinesVersion: String by project
val kotlinxSerializationVersion: String by project

dependencies {
    compileOnly(kotlin("reflect"))
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinxSerializationVersion")
}

configureSdkPublication()
I publish my lib in gitlab packageRegistry and i can see there is also a javadoc.jar the corresponding modules but still the consumer does not downloads it.
I found no way for dokka javadocs to be recognizable by the consumer, so in the end i used the java extenstions:
Copy code
java {
    withJavadocJar()
    withSourcesJar()
}
worked with minimal configuration.