SpineEventEngine / config

Dependencies and build configurations shared among subprojects
https://spine.io
Apache License 2.0
2 stars 3 forks source link

Add publishing of Dokka-generated documentation in Kotlin API mode #463

Open alexander-yevsyukov opened 1 year ago

alexander-yevsyukov commented 1 year ago

This PR in base introduces separation of artifacts generated by Dokka for Kotlin- and Java-based API mode of documentation.

In addition to standard Dokka HTML publication artifact, which serves the Java API perspective, we need to have another artifact, which contains documentation from the Kotlin API perspective.

Dokka setup for Kotlin API mode should be be checked to support the facility similar to ExcludeInternal doclet which strips API elements annotated with @Internal. Please see Configuration Options as a source of inspiration of how it may be implemented. It currently works for Java API mode and hopefully should work for Kotlin out of the box.

Currently there's only one dokkaHtml task, which does not comply with KMM modules because it produces at least two publications: one for commonMain and one for jvmMain source sets.

We need to have two API modes for all the modules (both JVM-only and KMM):

Here's the details of the issue that needs to solved. Java API mode is currently enabled by importing dokka-for-java script plugin. It adds a separate dependency for kotlin-as-java Dokka plugin:

fun DependencyHandlerScope.useDokkaForKotlinAsJava() {
    dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib)
}

When it comes to KMM module, we cannot use this approach because there are at least to publications. And we probably need to have a separate Configuration for jvm documentation which handles the dependency dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib).

The PR in base solves the above issue only partially as it uses Dokka for Kotlin mode for the logging module (which is KMM) and adds vanilla Javadoc artifact for the jvm publication:

publishing {
    publications.withType<MavenPublication> {
        if (name.contains("jvm", true)) {
            artifact(project.javadocJar())
        } else {
            artifact(project.dokkaKotlinJar())
        }
    }
}

Once the general documentation improvement is introduced as the result of addressing this issue, the base project (or the separate logging project, if we choose to extract it) needs to be adjusted accordingly.

alexander-yevsyukov commented 1 year ago

@armiol, FYI.