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

Modules with kapt plugin fails with implicit dependency error #3117

Open
adjorno opened this issue Aug 14, 2023 · 8 comments
Open

Modules with kapt plugin fails with implicit dependency error #3117

adjorno opened this issue Aug 14, 2023 · 8 comments
Labels
bug runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin

Comments

@adjorno
Copy link

adjorno commented Aug 14, 2023

Describe the bug
After ugrading Gradle to 8.2.1, Kotlin to 1.9.0 and Dokka to 1.8.20 the modules using kapt plugins started failing on :dokkaHtml gradle task execution with implicit dependency error.

Expected behaviour
Dokka successfully finishes.

Screenshots

    Reason: Task ':kaptmodule:dokkaHtml' uses this output of task ':kaptmodule:kaptDebugKotlin' 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 ':kaptmodule:kaptDebugKotlin' as an input of ':kaptmodule:dokkaHtml'.
      2. Declare an explicit dependency on 'kaptmodule:kaptDebugKotlin' from ':kaptmodule:dokkaHtml' using Task#dependsOn.
      3. Declare an explicit dependency on ':kaptmodule:kaptDebugKotlin' from ':kaptmodule:dokkaHtml' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

To Reproduce
run :dokkaHtml 2 times. It will fail on the 2nd run, probably something related to Gradle caching.

Dokka configuration
Configuration of dokka used to reproduce the bug

tasks.dokkaHtml.configure {
    outputDirectory.set(file("../documentation/kaptmodule"))
    this.dokkaSourceSets.getByName("main") {
        skipDeprecated.set(true)
        includeNonPublic.set(false)
        skipEmptyPackages.set(true)
        reportUndocumented.set(false)
        perPackageOption {
            matchingRegex.set(".*\\.internal.*") // will match internal and all sub-packages of it
            suppress.set(true)
        }
    }
}

Installation

  • Operating system: macOS 13.5
  • Build tool: Gradle v8.2.1
  • Dokka version: 1.8.20
@adjorno adjorno added the question A user question, can be resolved if the question is answered/resolved label Aug 14, 2023
@IgnatBeresnev
Copy link
Member

Hi! This is interesting... I'm struggling to see why Dokka would depend on kapt, but perhaps this is a variation of #3153?

Could you please update to Dokka 1.9.0 and try the workarounds suggested in #3153?

@fobidlim
Copy link

fobidlim commented Sep 4, 2023

Same errors on me, using Gradle 8.3, Kotlin 1.9.10, Dokka 1.9.0

build.gradle.kts

tasks.withType<DokkaTaskPartial>().configureEach {
            outputDirectory.set(layout.buildDirectory.get().dir("docs"))
            dokkaSourceSets {
                pluginsMapConfiguration.set(
                    mapOf(
                        "org.jetbrains.dokka.base.DokkaBase" to
                            """{ "separateInheritedMembers": true }"""
                    )
                )
            }
        }

It is same, whether belows added or not.

gradle.properties.kts

org.jetbrains.dokka.classpath.useNativeDistributionAccessor=true
org.jetbrains.dokka.classpath.useKonanDistribution=true
org.jetbrains.dokka.classpath.excludePlatformDependencyFiles=true
Reason: Task ':core:common:dokkaHtmlPartial' uses this output of task ':core:common:kaptDebugKotlin' 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 ':core:common:kaptDebugKotlin' as an input of ':core:common:dokkaHtmlPartial'.
      2. Declare an explicit dependency on ':core:common:kaptDebugKotlin' from ':core:common:dokkaHtmlPartial' using Task#dependsOn.
      3. Declare an explicit dependency on ':core:common:kaptDebugKotlin' from ':core:common:dokkaHtmlPartial' 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.

Reason: Task ':core:common:dokkaHtmlPartial' uses this output of task ':core:common:kaptReleaseKotlin' 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 ':core:common:kaptReleaseKotlin' as an input of ':core:common:dokkaHtmlPartial'.
      2. Declare an explicit dependency on ':core:common:kaptReleaseKotlin' from ':core:common:dokkaHtmlPartial' using Task#dependsOn.
      3. Declare an explicit dependency on ':core:common:kaptReleaseKotlin' from ':core:common:dokkaHtmlPartial' 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.

@IgnatBeresnev
Copy link
Member

@fobidlim thanks for trying it out!

Is the project where it is happening open source by any chance? Having a reproducer would simplify debugging by a lot

@fobidlim
Copy link

fobidlim commented Sep 5, 2023

@IgnatBeresnev The project is not open source.
In my case, migrate kapt to ksp, problem is solved.

@adjorno
Copy link
Author

adjorno commented Sep 5, 2023

@IgnatBeresnev Our project is also not open-source. I solved the issue by adding the explicit dependency in all kapt modules:

afterEvaluate {
    tasks["dokkaHtml"].dependsOn(tasks.getByName("kaptReleaseKotlin"), tasks.getByName("kaptDebugKotlin"))
}

@milgner
Copy link

milgner commented Sep 21, 2023

@adjorno much appreciated! I had to slightly adopt it for my case but it got rid of the message!

target.afterEvaluate {
    target.tasks.named("dokkaHtmlPartial").configure {
        dependsOn(target.tasks.getByName("kaptKotlin"))
    }
}

@valya1
Copy link

valya1 commented Oct 13, 2023

We have the same issue with using dokka + kapt in our project, will it be fixed in future dokka release?

@vmishenev vmishenev added bug runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin and removed question A user question, can be resolved if the question is answered/resolved labels Oct 21, 2023
@lmachacek
Copy link

@adjorno & @milgner Thanks guys for the inspiration! In our case this helped:

    afterEvaluate {
        tasks.named("dokkaJavadoc").configure {
            dependsOn(tasks.getByName("kaptKotlin"))
        }
    }

We are using Gradle 8.5, Dokka 1.9.10 and Kotlin 1.9.21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin
Projects
None yet
Development

No branches or pull requests

7 participants