Hi, I'm trying to build HTML docs using dokka for ...
# dokka
w
Hi, I'm trying to build HTML docs using dokka for a project which also uses Dagger (and therefore kapt) in gradle. When running
./gradlew build dokkaHtml
I get an error from gradle which I interpret as meaning that dokka is generating documentation from generated code without the appropriate task dependency being declared:
Copy code
> Task :metrics:kaptKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':metrics:kaptKotlin' (type 'KaptWithoutKotlincTask').
  - Gradle detected a problem with the following location: '[redacted]/metrics/build/tmp/kapt3/classes/main'.
    
    Reason: Task ':metrics:dokkaHtml' uses this output of task ':metrics:kaptKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':metrics:kaptKotlin' as an input of ':metrics:dokkaHtml'.
      2. Declare an explicit dependency on ':metrics:kaptKotlin' from ':metrics:dokkaHtml' using Task#dependsOn.
      3. Declare an explicit dependency on ':metrics:kaptKotlin' from ':metrics:dokkaHtml' using Task#mustRunAfter.
    
    For more information, please refer to <https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency> in the Gradle documentation.
I can work around this by declaring a dependency as described in the error message, but I think my preference would be for dokka to ignore generated code. Has anyone run into a similar problem? Any advice? Thanks.
i
Hi! Unfortunately, this is a known issue for which we don't have a solution yet: https://github.com/Kotlin/dokka/issues/3117 There's a configuration option called
suppressGeneratedFiles
, which is set to
true
by default. It ignores generated files from
build/generated
, but it's implementation is that it adds these files to the
suppressedFiles
option, so it effectively still knows about them and it might be causing the undeclared dependency - this is just a guess though. We're unlikely to fix it for the current Dokka Gradle plugin as we're focusing on the new plugin which will address this and other problems, so the best bet is to find a suitable local workaround for now. Sorry for the inconvenience.
w
Thanks, I added the task dependency and the error went away. If I submitted a PR that enabled a better work-around, do you think it would be accepted?