plugins { kotlin("jvm") version "1.7.10" id("org.jetbrains.dokka") version ("1.7.10") `java-library` `maven-publish` } repositories { mavenCentral() } dependencies { implementation(kotlin("stdlib")) testImplementation(kotlin("test-junit")) } val dokkaJavadocJar by tasks.register("dokkaJavadocJar") { dependsOn(tasks.dokkaJavadoc) from(tasks.dokkaJavadoc.flatMap { it.outputDirectory }) archiveClassifier.set("javadoc") } val dokkaHtmlJar by tasks.register("dokkaHtmlJar") { dependsOn(tasks.dokkaHtml) from(tasks.dokkaHtml.flatMap { it.outputDirectory }) archiveClassifier.set("html-doc") } publishing { publications { register("library") { from(components["java"]) version = "1.0.0" groupId = "demo" artifactId = "dokka-library-publishing-example" artifact(dokkaJavadocJar) artifact(dokkaHtmlJar) } } }