Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.41k stars 402 forks source link

Gradle 7 incompatibility due to implicit dependency. #1833

Open ZacSweers opened 3 years ago

ZacSweers commented 3 years ago

Describe the bug Gradle 7.0 reports this issue for multiple dokka tasks

> Task :moshi-metadata-reflect:javadocsJar
Execution optimizations have been disabled for task ':moshi-metadata-reflect:javadocsJar' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/home/runner/work/MoshiX/MoshiX/docs/0.x'. Reason: Task ':moshi-metadata-reflect:javadocsJar' uses this output of task ':moshi-adapters:dokkaHtml' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.

Expected behaviour

Dokka should not have gradle issues

Screenshots

N/A

To Reproduce Run Dokka with Gradle 7.0

Here's an example: https://github.com/ZacSweers/MoshiX/runs/2310971282

Dokka configuration Configuration of dokka used to reproduce the bug

    tasks.named<DokkaTask>("dokkaHtml") {
      outputDirectory.set(rootProject.rootDir.resolve("docs/0.x"))
      dokkaSourceSets.configureEach {
        skipDeprecated.set(true)
        externalDocumentationLink {
          url.set(URL("https://square.github.io/okio/2.x/okio/"))
        }
        externalDocumentationLink {
          url.set(URL("https://square.github.io/moshi/1.x/moshi/"))
        }
      }
    }

Installation

Additional context None

kamildoleglo commented 3 years ago

Haven't got time to check that yet, but are you sure that this is not a problem on your side? The fragment

'moshi-metadata-reflect:javadocsJar' uses this output of task ':moshi-adapters:dokkaHtml' without declaring an explicit or implicit dependency.

indicates that you have a task called javadocsJar that has a definition like (I'm guessing):

task javadocsJar { 
    from(dokkaHtml.outputDir)
}

while it should have a dependsOn also:

task javadocsJar { 
    dependsOn(dokkaHtml)
    from(dokkaHtml.outputDir)
}
ZacSweers commented 3 years ago

The only thing that could be setting them is this plugin, which does set explicit dependencies: https://github.com/vanniktech/gradle-maven-publish-plugin/blob/0.14.2/src/main/kotlin/com/vanniktech/maven/publish/tasks/JavadocsJar.kt

ZacSweers commented 3 years ago

This looks like a wider issue with Dokka reading outputs from tasks in a generic way. Here is the same issue but using generated code from another plugin (Wire)

  - Gradle detected a problem with the following location: '/home/runner/work/slack-gradle-plugin/slack-gradle-plugin/slack-plugin/build/generated/source/wire'. Reason: Task ':slack-plugin:dokkaHtml' uses this output of task ':slack-plugin:generateMainProtos' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Fachher commented 3 years ago

Hi all. Is there some flag to break the build if gradle detects a problem?

Thank you in advance

UPDATE: Answer found ./gradlew build --warning-mode=fail

JamshedAlamQaderi commented 1 year ago

This looks like a wider issue with Dokka reading outputs from tasks in a generic way. Here is the same issue but using generated code from another plugin (Wire)

  - Gradle detected a problem with the following location: '/home/runner/work/slack-gradle-plugin/slack-gradle-plugin/slack-plugin/build/generated/source/wire'. Reason: Task ':slack-plugin:dokkaHtml' uses this output of task ':slack-plugin:generateMainProtos' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.

Hi @ZacSweers , How did you solved this issue?

CyxouD commented 11 months ago

I got this error when I replaced dependsOn with .mustRunAfter. It was needed for other task to fix error "Cannot change dependencies of dependency configuration after it has been resolved." after downgrading to Gradle plugin 7.2.2