dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Nested multimodule tasks are broken in Gradle 8

Open dellisd opened this issue 2 years ago • 9 comments
trafficstars

Describe the bug If you have a root gradle project that you run a multimodule dokka task on (e.g. dokkaHtmlMultiModule) which includes a gradle project that itself has a multimodule setup (i.e. also has a dokkaHtmlMultiModule task), the root dokkaHtmlMultiModule task will fail with an implicit dependency error.

A problem was found with the configuration of task ':dokkaHtmlMultiModule' (type 'DokkaMultiModuleTask').
  - Gradle detected a problem with the following location: '/Users/derekellis/projects/sqldelight/sqldelight-compiler/dialect/build/dokka/htmlPartial'.
    
    Reason: Task ':dokkaHtmlMultiModule' uses this output of task ':sqldelight-compiler:dokkaHtmlMultiModule' 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 ':sqldelight-compiler:dokkaHtmlMultiModule' as an input of ':dokkaHtmlMultiModule'.
      2. Declare an explicit dependency on ':sqldelight-compiler:dokkaHtmlMultiModule' from ':dokkaHtmlMultiModule' using Task#dependsOn.
      3. Declare an explicit dependency on ':sqldelight-compiler:dokkaHtmlMultiModule' from ':dokkaHtmlMultiModule' using Task#mustRunAfter.
    
    Please refer to https://docs.gradle.org/8.0.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.

Note: this only happens on clean builds. If the task(s) are using a cached result of a successful run of the tasks, this error won't be thrown.

Expected behaviour It should build normally.

To Reproduce

  1. Set up a multimodule gradle project with Gradle 8+
  2. Add a multimodule gradle subproject to the root project
  3. Try to run the root multimodule task

Installation

  • Operating system: macOS
  • Build tool: Gradle 8.0.2
  • Dokka version: 1.8.10

dellisd avatar Mar 31 '23 14:03 dellisd

Related to

  • #2700
  • #1752

I've re-written the Dokka Gradle Plugin to be more compatible with the Gradle API if you'd like to try it:

https://github.com/adamko-dev/dokkatoo

The plan is to merge this plugin upstream, eventually #2839

aSemy avatar Mar 31 '23 15:03 aSemy

Same error for me, reproducible in GitLab CI: job | code.

Reproduced with Gradle 8.0.2, Dokka 1.7.20 and 1.8.10.

CLOVIS-AI avatar Apr 01 '23 14:04 CLOVIS-AI

Is there any workaround available beside using dokkatoo?

hfhbd avatar May 28 '23 12:05 hfhbd

@hfhbd you might try this workaround. Have you read this related issue and thread?

jeffdgr8 avatar May 28 '23 17:05 jeffdgr8

Yes, but I don't use native targets, only multiple nested JVM modules and I just switched to dokkatoo.

hfhbd avatar May 28 '23 19:05 hfhbd

After migrating to Gradle 8.1.1 and Dokka 1.8.20, without using any of the mentioned workarounds, I do not have this problem anymore.

CLOVIS-AI avatar Jun 17 '23 09:06 CLOVIS-AI

Nevermind, it seems to depend on the project. I have another project using Gradle 8.1.1 and Dokka 1.8.20, in which the workaround is still necessary.

CLOVIS-AI avatar Jun 25 '23 15:06 CLOVIS-AI

Seeing this in AWS SDK for Kotlin when trying to upgrade to Gradle 8.2.1 and Dokka 1.8.20.

aajtodd avatar Jul 26 '23 12:07 aajtodd

I have experienced the same issue when I call Dokka like ./gradlew dokkaHtmlMultiModule. It runs all dokkaHtmlMultiModule tasks in subprojects, that have children. See Gradle: executing tasks by name . So it causes an output of the dokkaHtmlPartial task to be used by two different the dokkaHtmlMultiModule tasks without declaring dependency between them.

Workaround Run ./gradlew :dokkaHtmlMultiModule (with a colon) instead of ./gradlew dokkaHtmlMultiModule. It will run the :dokkaHtmlMultiModule task of the only root project. See Gradle: executing tasks by fully qualified name.

Also, there is a possible workaround to disable other unnecessary dokkaHtmlMultiModule tasks or declare an explicit dependency on them.

vmishenev avatar Aug 27 '23 16:08 vmishenev

Should not be an issue in Dokka 2.0.0 in Dokka Gradle plugin v2 with reworked aggregation setup

whyoleg avatar Dec 16 '24 16:12 whyoleg

Workaround Run ./gradlew :dokkaHtmlMultiModule (with a colon) instead of ./gradlew dokkaHtmlMultiModule. It will run the :dokkaHtmlMultiModule task of the only root project. See Gradle: executing tasks by fully qualified name.

But with gradle :dokkaGeneratePublicationHtml (I use Dokka 2.0.0 V2) there is an another error:

Execution failed for task ':dokkaGeneratePublicationHtml'.
> Could not resolve all files for configuration ':dokkaHtmlPublicationPluginResolver~internal'.
   > Could not resolve project(:project ':project-1').
     Required by:
         root project :
      > Could not resolve project(:project ':project-1').
         > Could not get resource 'https://**nexus**/project(/project%20'/project-1')/project%20'project-1').pom'.
            > Could not GET 'https://**nexus**/project(/project%20'/project-1')/project%20'project-1').pom'. Received status code 400 from server: Bad Request

man85 avatar Jun 10 '25 11:06 man85

Should not be an issue in Dokka 2.0.0 in Dokka Gradle plugin v2 with reworked aggregation setup

Same problem in V2

man85 avatar Jun 10 '25 11:06 man85