Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle 7 incompatibility due to implicit dependency. #1833

Open
ZacSweers opened this issue Apr 10, 2021 · 6 comments
Open

Gradle 7 incompatibility due to implicit dependency. #1833

ZacSweers opened this issue Apr 10, 2021 · 6 comments
Labels
bug runner: gradle plugin v2 Issues fixed by Dokka Gradle Plugin v2 - see https://github.com/Kotlin/dokka/issues/3131 runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin
Milestone

Comments

@ZacSweers
Copy link

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

  • Operating system: N/A
  • Build tool: Gradle v7
  • Dokka version: 1.4.30

Additional context
None

@ZacSweers ZacSweers added the bug label Apr 10, 2021
@ZacSweers ZacSweers changed the title Gradle 7 incompatibility Gradle 7 incompatibility due to implicit dependency. Apr 10, 2021
@kamildoleglo
Copy link
Contributor

kamildoleglo commented Apr 10, 2021

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
Copy link
Author

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
Copy link
Author

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
Copy link

Fachher commented Jul 22, 2021

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
Copy link

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
Copy link

CyxouD commented Oct 23, 2023

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

@adam-enko adam-enko added the runner: gradle plugin v2 Issues fixed by Dokka Gradle Plugin v2 - see https://github.com/Kotlin/dokka/issues/3131 label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug runner: gradle plugin v2 Issues fixed by Dokka Gradle Plugin v2 - see https://github.com/Kotlin/dokka/issues/3131 runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin
Projects
None yet
Development

No branches or pull requests

9 participants