Roberto Leinardi
01/10/2025, 3:03 PMdokkaHtmlMultiModule {
outputDirectory.set(rootDir.resolve("docs/dokka"))
}
Everything worked seamlessly! π
With version 2.x, it seems I now have to explicitly declare all the Dokka dependencies for the modules in the root `build.gradle.kts`:
dependencies {
dokka(project(":childProjectA"))
dokka(project(":childProjectB"))
}
This manual step is tricky for me since my project has both dynamic modules (loaded via a JSON config) and static modules. In version 1.x, I could rely on Gradle's build conventions for automation, but now I feel like I have two sources of truth:
1. The standard Gradle configuration for modules.
2. The new Dokka dependencies I need to define manually.
Is there an alternative approach for multimodule projects that would let me mark a project as a Dokka dependency directly in the moduleβs build.gradle.kts
? Something that works well with Gradle build conventions and can be automated?
Thanks in advance for your insights!mbonnin
01/10/2025, 3:08 PMmbonnin
01/10/2025, 3:08 PMmbonnin
01/10/2025, 3:09 PMmbonnin
01/10/2025, 3:10 PMRoberto Leinardi
01/10/2025, 3:11 PMmbonnin
01/10/2025, 3:11 PMmbonnin
01/10/2025, 3:12 PMallprojects {
configuration.dependencies.add("myConfig", project(":${it.name}")
}
mbonnin
01/10/2025, 3:13 PMRoberto Leinardi
01/10/2025, 3:14 PMRoberto Leinardi
01/10/2025, 3:14 PMmbonnin
01/10/2025, 3:14 PMmbonnin
01/10/2025, 3:15 PMRoberto Leinardi
01/10/2025, 3:30 PMmbonnin
01/10/2025, 3:34 PMCLOVIS
01/11/2025, 9:40 PMbuild.gradle.kts
?
The Gradle team is actively fighting against this. They are experimenting with lazy configuration (see "configuration on demand"), with which only projects explicitly requested are configured. With what you're trying to do, when it becomes stable, any module not referenced in the root module just won't be executed and won't appear in the documentation.CLOVIS
01/11/2025, 9:41 PMIt shouldn't be so difficult to configure Dokka for a multimodule project and version 2.x should not drop features from version 1.x.The fact that the old Dokka plugin worked like that was one of the main causes of stability and performance problems, it's almost the primary reason for why Dokkatoo was created, and thus we get Dokka 2
Adam Semenenko
01/13/2025, 10:23 AMmbonnin
01/13/2025, 10:29 AMAdam Semenenko
01/13/2025, 10:31 AM:docs
subproject then collects all documentable subprojects https://github.com/JetBrains/kotlin-wrappers/blob/pre.860/docs/build.gradle.kts#L24-L30
(DGP might be able to do this automatically, but shared BuildServices break when the applied plugins aren't identical in every subproject https://github.com/gradle/gradle/issues/17559 gradle intensifies)mbonnin
01/13/2025, 10:35 AMmbonnin
01/13/2025, 10:35 AMmbonnin
01/13/2025, 11:03 AMshared BuildServices break when the applied plugins aren't identical in every subprojectMissed that one: that's a cool idea https://github.com/gradle/gradle/issues/31846
mbonnin
01/13/2025, 11:09 AMaddAllLater
π€Adam Semenenko
01/13/2025, 11:09 AMdependencies { allprojects { dokka(project) } }
works).
β’ When aggregating, the subprojects are set here https://github.com/Kotlin/dokka/blob/0c8711917c367340368d17ee11c6a0867d61c655/dokka-runners/dokka-gradle-plugin/src/main/kotlin/formats/DokkaFormatPlugin.kt#L100-L102
β’ incomingArtifactFiles
does some complicated matching/filtering, and sets lenient(true)
https://github.com/Kotlin/dokka/blob/623ee350ad054f7bd893cf03348fd10781fe0903/dokka-runners/dokka-gradle-plugin/src/main/kotlin/dependencies/ModuleComponentDependencies.kt#L62-L75Adam Semenenko
01/13/2025, 11:10 AMorg.gradle.strictbuildclasspath=true
would be cool
There's like 10 different ways to add Gradle plugins, it's very confusingmbonnin
01/13/2025, 11:12 AMallprojects {
dokka(project(":$path")) // non-dokka projects will be ignored
}
Which would effectively solve @Roberto Leinardi issue? Not the cleanest thing but should do?CLOVIS
01/13/2025, 1:11 PMmbonnin
01/13/2025, 1:12 PMmbonnin
01/13/2025, 1:13 PMdokka {
aggregate = false // defaults to true
}
CLOVIS
01/13/2025, 1:19 PMmbonnin
01/13/2025, 1:22 PMmbonnin
01/13/2025, 1:22 PMmbonnin
01/13/2025, 1:22 PMmbonnin
01/13/2025, 1:23 PMBuildService
solution as far as I understand?mbonnin
01/13/2025, 1:23 PMAdam Semenenko
01/15/2025, 9:22 AMdependencies {
// dokka(project)
// dokka(project(":childProjectA"))
// dokka(project(":childProjectB"))
allprojects { dokka(project) }
}
But I would really recommend explicitly listing the dependencies, because allprojects {}
is a landmine and can cause issues.mbonnin
01/15/2025, 9:27 AMI would really recommend explicitly listing the dependenciesAgreed
becauseUsingis a landmine and can cause issues.allprojects {}
allprojects {}
is fine as long as you're only using Project.name
and Project.path
inside the lambda.mbonnin
01/15/2025, 9:28 AMallprojects {}
solution is the lenient dependency resolution. I've been bitten by this already and it's a massive pain to debugmbonnin
01/15/2025, 9:28 AM