Split package (cross module) links not working
Question Hello, I am currently working on the mockk project and try to migrate to dokka v2. I've copied your configuration from your multi-module example. I've encountered two problems.
see links and return types from different modules can't be resolved
Is there a simple fix for that? We are creating sourceSets like this:
kotlin {
jvm()
sourceSets {
val commonMain by getting {
dependencies {
implementation(projects.modules.mockk)
}
}
}
}
Aggregation of android projects are not working
When i run the dokkaGenerate task for each android project they are created.
When i run the dokkaGenerate task in the docs project, the android projects are not generating dokka files in build output. In some is the dokka-module folder missing. In some is dokka-module folder with empty html/module folder and the module-descriptor.json.
Only multiplatform modules can be aggregated into the full html documentation.
Installation
- Operating system: Linux
- Build tool: Gradle 9.2.1, Android Gradle plugin 8.13.0
- Dokka version: 2.1.0
Hey! Could you share a branch with your configuration so that I can investigate it?
Thank you for looking into it. This is the branch https://github.com/jgrnrt/mockk/tree/junit-6 . Please ignore tests.
Here is what I have found so far. First, regarding unresolved links (based on logs):
- [io.mockk.slot] and on other declarations in that file - correctly unresolved, as
slotfunction is declared in mockk project, which is not a dependency ofmockk-dsl. This link was previously incorrectly resolved in the IDE, but with K2 in place, it's not resolved in the IDE either. - [io.mockk.junit5.MockKExtension] and in other annotations - correctly unresolved, because it's not allowed to reference from
commontojvmsource-set. - [io.mockk.every] and some other links in the file - this is unresolved, probably because there is a split package for the
io.mockkpackage, which is both available in themockkandmockk-dslprojects. The same is most likely happening for [MockKMatcherScope.capture] and return types of functions likeslot. Dokka doesn't work correctly when there is a split package. There was an attempt to fix such links in https://github.com/Kotlin/dokka/pull/3425; however, it appears that in cases where the module itself (mockk) has the same package as the module to which functions are referred (mockk-dsl) and vice versa, the fix doesn't work. It requires further investigation to determine if we can support this.
Were those issues present previously, with an earlier Dokka version?
Second, regarding aggregation. Based on the configuration in the docs module:
dependencies {
dokka(projects.modules.mockk) // works
dokka(projects.modules.mockkAgent) // works
dokka(projects.modules.mockkAgentAndroidDispatcher) // empty - no kotlin plugin
dokka(projects.modules.mockkAgentApi) // works
dokka(projects.modules.mockkAndroid) // empty - no sources
dokka(projects.modules.mockkBdd) // work
dokka(projects.modules.mockkBddAndroid) // empty - no declarations
dokka(projects.modules.mockkCore) // works
dokka(projects.modules.mockkDsl) // works
}
I see that the projects, where nothing is generated, are projects without sources or declarations. Only one project, which might be supported, is mockkAgentAndroidDispatcher, for that, you need to add the kotlin plugin there to create corresponding Dokka source sets.
Hope this helps!
I've implemented some fixes:
- removed incorrect links
- added missing Unit declarations, which needed to be explicitly typed
- added kotlin plugin for dispatcher module
- added a missing android module (which probably confused me in the first place)
I hope you'll be able to support split packages in the future. Until then, I suppose we'll have to accept the error messages for some parameter and return types.
Thank you very much for your support and your well-written explanations.