I'm trying to use the latest dokka to create javad...
# dokka
m
I'm trying to use the latest dokka to create javadocs in a multipaltform project. It's a jvm+ios project. But I get
Copy code
Pre-generation validity check failed: Dokka Javadoc plugin currently does not support generating documentation for multiplatform project. Please, adjust your configuration
I was hoping that this config would work, but it doesn't
Copy code
tasks {
    dokkaJavadoc {
        outputDirectory.set(project.rootProject.file("$buildDir/dokka"))
        dokkaSourceSets {
            named("commonMain") {
                sourceRoots.from(kotlin.sourceSets.getByName("commonMain").kotlin.srcDirs)
            }
        }
    }
}
m
I think that you need to suppress the ones you wouldn’t like to have using
configureEach
or suppress all and then add your custom
m
I tried this:
Copy code
dokkaSourceSets {
            configureEach {
                if(displayName.get() != "common") suppress.set(true)
            } 
            named("commonMain") {
                sourceRoots.from(kotlin.sourceSets.getByName("commonMain").kotlin.srcDirs)
            }
        }
But I get an error on `dokkaJavadoc`: Empty collection can't be reduced.
To add more context. I have Just this in kmm config
Copy code
kotlin {
    jvm()
    ios()
And my directory containing the common code is
commonMain
. So rpetty standard config
This also throws Empty collection can't be reduced.
Copy code
dokkaSourceSets {
            configureEach {
                if(displayName.get() != "common"){
                    suppress.set(true)
                } else {
                    sourceRoots.from(kotlin.sourceSets.getByName("commonMain").kotlin.srcDirs)
                }
            }
m
ok, i’ve debugged it a little bit more and the issue was that your common does not have the JVM platform and dokka expects it if it outputs javadoc. So to make it work you can do something like this:
Copy code
dokkaSourceSets {
            configureEach {
                suppress.set(true)
            }

            val commonMain by getting {
                suppress.set(false)
                platform.set(org.jetbrains.dokka.Platform.jvm)
            }
}
Please keep in mind, that javadoc does not support more than 1 platform (JVM)
m
it did build thank you! What exactly do you mean by "Please keep in mind, that javadoc does not support more than 1 platform (JVM)" What I'm trying to do right now is satisfy mavenCentral requirements for javadocs. I'm aware that I can always post an empty javadoc, but wanted to do it properly. Do you say that even though I'm generating javadocs with dokka for jvm, I'm still missing it for ios target? I'm looking at my mavenLocal and I can see files like
mylibsarm64-0.3.4-javadoc
m
We use html output in publication and didn’t have any issues with it. You might try it as well 🙂
m
like dokkaHtml and save as
sth.javadoc.jar
and it's accepted by maven central? 😄
k
dokkaHtml
then create a jar from that (with a new Gradle task)
m
I'm currently in the process of "closing" the repo on maven central. It takes a lot of time but I guess if it works, then it means that the javadoc config worked. If not, I will try html. Thank you guys 🙂
Yep, it worked