dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Error Task ':projec-2:dokkaGeneratePublicationHtml' uses this output of task ':projec-1:dokkaGeneratePublicationHtml' without declaring an explicit or implicit dependency.

Open man85 opened this issue 6 months ago • 3 comments

Describe the bug Muti-module project with

dependencies {
    dokka(project(":projec-1"))
    dokka(project(":projec-2"))
}

I get an error like this:

    Reason: Task ':projec-2:dokkaGeneratePublicationHtml' uses this output of task ':projec-1:dokkaGeneratePublicationHtml' 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 ':projec-1:dokkaGeneratePublicationHtml' as an input of ':projec-2:dokkaGeneratePublicationHtml'.
      2. Declare an explicit dependency on ':projec-1:dokkaGeneratePublicationHtml' from ':projec-2:dokkaGeneratePublicationHtml' using Task#dependsOn.
      3. Declare an explicit dependency on ':projec-1:dokkaGeneratePublicationHtml' from ':projec-2:dokkaGeneratePublicationHtml' using Task#mustRunAfter.

when running gradle dokkaGeneratePublicationHtml.

Expected behaviour gradle dokkaGeneratePublicationHtml is running successfully

Screenshots If applicable, add screenshots to help explain your problem

To Reproduce May be because project-1 build.gradle.kts contains

dependencies {
    api(project(":project-1"))
}

Dokka configuration Configuration of dokka used to reproduce the bug


Installation

  • Operating system: Linux Ubuntu
  • Build tool: Gradle v8.12.1
  • Dokka version: 2.0.0

Additional context Add any other context about the problem here

man85 avatar Jun 06 '25 13:06 man85

I made dependencies between tasks like this:

tasks.named("dokkaGeneratePublicationHtml") {
    dependsOn(project(":project-1").tasks.named("dokkaGeneratePublicationHtml"))
}

but ran into circular dependencies issue

man85 avatar Jun 09 '25 06:06 man85

I added a lot of

tasks.named("dokkaGenerateModuleHtml") {
    dependsOn(project(":another-subproject").tasks.named("dokkaGeneratePublicationHtml"))
    ...
}

tasks.named("dokkaGeneratePublicationHtml") {
    dependsOn(project(":another-subproject").tasks.named("dokkaGeneratePublicationHtml"))
    ...
}

into build.gradle.kts and after that I got compilation errors (unresolved) But project can be compiled with gradle build -x test

The multiproject has 110 subprojects and it's hard to add task dependencies to every build.gradle.kts.

man85 avatar Jun 09 '25 10:06 man85

Hi, thanks for the report.

The error message Task ':projec-2:dokkaGeneratePublicationHtml' uses this output of task ':projec-1:dokkaGeneratePublicationHtml' without declaring an explicit or implicit dependency. indicates the buildscripts are doing some something unconventional. The dokkaGeneratePublicationHtml tasks are supposed to be the final aggregated output, and not directly depended on across projects. But I can't say more than that without looking at the Gradle configuration.

Are you able to share the project? Or can you create a reproducer?

adam-enko avatar Nov 03 '25 08:11 adam-enko