https://kotlinlang.org logo
Title
n

Niklas

04/26/2023, 6:32 AM
Hey, i got a problem with my dokka documentation. My classes get printed 5 times and i got these logs in the console. Does anyone know, what causes this 'issue'?
j

jush

04/26/2023, 7:42 AM
Do you happen to have multiple source sets (or android variants) that contain the same class definitions?
n

Niklas

04/26/2023, 7:53 AM
I don't think we have multiple source sets. But we got multiple buildvariants like, debug, release, etc. And some build flavors. May that be the cause?
j

jush

04/26/2023, 7:56 AM
yeah, I think the build flavors will affect. Do you have the same classes in the different build flavors?
n

Niklas

04/26/2023, 8:05 AM
yeah, it uses the sam classes. Is there a way to build the documentation only for one flavor? Or to supress the other ones?
j

jush

04/26/2023, 8:14 AM
It’s a bit tricky but the way I did it is by disabling all dokkaSourceSets except the one for the variant name:
// First disable all dokka source sets except the `variantName` one that will be used later
    dokkaSourceSets.configureEach {
      suppress.set(name != variantName)
    }
then manually add the source sets to the dokka source set:
// To avoid undocumented inherited methods/classes we need to join all the source roots
    // related to the flavor release variant into one source set (`variantName`).
    dokkaSourceSets.named(variantName) {
      sourceSets.forEach {
        it.javaDirectories.forEach { javaDirectory ->
          sourceRoots.from(javaDirectory)
        }
      }
    }
sourceSets
can be acquired from the android plugin:
libraryVariants.all {
   // here you can access sourceSets
}
Unfortunately, I can’t share my solution since it’s quite tight to our project. Hopefully this points you towards the right direction
n

Niklas

04/26/2023, 8:16 AM
Yeah, that looks great! Thank you so far! 🙂
i

Ignat Beresnev

04/26/2023, 1:28 PM
Hey! Unfortunately, I don't know much about android and its build variants to suggest a better solution (if there's even one), but it would help if you could create an issue and describe your use case for why you want to do it or which problem it solves. There's a number of android-specific issues already, some of them are related to build variants, so hopefully one day we'll get to addressing them