Hi, I am currently migrating to Dokka 2, but I am ...
# dokka
p
Hi, I am currently migrating to Dokka 2, but I am unable to define multiple Dokka tasks in order to generate dedicated reports for test or main source code. In Dokka 1, we had the following two gradle tasks that could be executed independently and generated either :
task generateTestDocs(type: DokkaTask) {
dokkaSourceSets {
...
}
}
task generateAppDocs(type: DokkaTask) {
dokkaSourceSets {
...
}
}
Now in Dokka 2, whenever I register a DokkaTask like so I get an exception:
tasks.register<DokkaTask>("generateTestDocs") {
outputDirectory.set(layout.buildDirectory.dir("testDocs"))
...
}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateTestDocs'.
> java.lang.ClassNotFoundException: org.jetbrains.dokka.DokkaBootstrapImpl
I have read through the migration guide, but couldnt really determine whether that should still be an option. Generating a single output file does work, but we are required by process to have them independently. Could you give me any suggestion howto generate independent reports for different source sets within one project?
a
hi, you can achieve this in DGPv2 by creating new DokkaSourceSets in the
dokka {}
dsl, instead of manually creating tasks. DGPv2 will automatically create and configure the required tasks for all DokkaSourceSets.
Copy code
dokka {
    dokkaSourceSets.register("appDocs") {
        // ...
    }

    dokkaSourceSets.register("testDocs") {
        // ...
    }
}
p
Hi Adam, thanks for your quick response. Following your example, I have done the following in a sandbox project:
dokka{
dokkaSourceSets.register("appDocs"){
displayName.set("Main")
}
dokkaSourceSets.register("testDocs"){
displayName.set("Test")
sourceRoots.from(file("src/test/java"))
suppress.set(false)
}
}
The result is a single report which contains both sourceSets, please see my screenshot. Is it possible to generate completely independent reports for each sourceSet? Am I doing something wrong here?
a
Ah I see, sorry, I think I misunderstood. So you need to create multiple, independent publications based on the same source code, but the sources might have different configuration (e.g. to include test sources)?
p
Yes, exactly. Each publication needs to have their own source root and visibility configuration.
a
Ahh yes, I understand now. I thought creating multiple publications was still possible in DGPv2, but I'm struggling to remember how. Or possibly I'm remembering that we decided not to implement it initially because of low usage, or there was another workaround. I'm working on some other tasks at the moment so I won't have a chance to look into it for a few weeks. Could you make a GitHub issue for this please?
p
Thanks for your help! I have opened the corresponding github issue #4079.