I’m trying to get a generated .kt file to show up ...
# dokka
d
I’m trying to get a generated .kt file to show up in the
dokkaHtml
output for my Gradle Android library module and I can’t get it to work. The file is generated in
build/generated/source/myDir/main
, is added to
android.sourceSets.main.java.srcDirs
, and is used in source code which successfully compiles. I’ve tried a bunch of different permutations of configuration that looks like this:
Copy code
dokkaHtml {
    dokkaSourceSets {
        configureEach {
            jdkVersion.set 8

            logger.lifecycle "$project adding sourceRoot $myDirRoot"
            sourceRoot.from(file(stringsRoot))
        }
    }
}
With this exact configuration,
:myModule:dokkaHtml
fails due to “> NamedDomainObjectContainer#create(String) on GradleDokkaSourceSetBuilder container cannot be executed in the current context.” If I use
sourceRoot(
(without the
.from
), it doesn’t fail, but the generated class still doesn’t appear in the docs. I’ve also tried adding it as a custom source set or setting
myDirRoot
as an absolute or relative path, to no avail. Any clue what I’m doing wrong?
m
Could you elaborate more on what those sources contain? Are they AIDL-s (generally content of
generated
folder in android)?
d
There’s a single Kotlin
object
class in a .kt file in the referenced directory. (I’m not actually generating anything, just copying the file there as a POC before putting in the codegen work.)
a
i too try add generated sources into dokka output, but can't... if i just copy paste code from generated dir into main dir - all generated. but if sources in build/generated in output it will lost. i now think that in dokka internals contains autoskip
build
dir 😞 for me this needed with https://github.com/icerockdev/moko-network generated api classes
https://github.com/Kotlin/dokka/issues/1776 i create issue about it 😞
d
Nice find! I gave the issue a 👍