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

Nested multimodule tasks are broken in Gradle 8 #2954

Open
dellisd opened this issue Mar 31, 2023 · 9 comments
Open

Nested multimodule tasks are broken in Gradle 8 #2954

dellisd opened this issue Mar 31, 2023 · 9 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

@dellisd
Copy link

dellisd commented Mar 31, 2023

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 dellisd added the bug label Mar 31, 2023
@aSemy
Copy link
Contributor

aSemy commented Mar 31, 2023

Related to

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

@CLOVIS-AI
Copy link
Contributor

CLOVIS-AI commented Apr 1, 2023

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

Reproduced with Gradle 8.0.2, Dokka 1.7.20 and 1.8.10.

@IgnatBeresnev IgnatBeresnev added the runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin label Apr 2, 2023
@hfhbd
Copy link
Contributor

hfhbd commented May 28, 2023

Is there any workaround available beside using dokkatoo?

@jeffdgr8
Copy link

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

@hfhbd
Copy link
Contributor

hfhbd commented May 28, 2023

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

swankjesse pushed a commit to cashapp/zipline that referenced this issue Jun 1, 2023
Nesting 'testing' inside 'zipline' and 'tests' inside 'zipline-kotlin-plugin'
make it difficult to use the binary-compatibility-validator and dokka plugins.

The binary-compatibility-validator plugin applies itself to nested modules.
We don't want this.

The dokka plugin crashes on multi-module builds.
Kotlin/dokka#2954
swankjesse pushed a commit to cashapp/zipline that referenced this issue Jun 1, 2023
Nesting 'testing' inside 'zipline' and 'tests' inside 'zipline-kotlin-plugin'
make it difficult to use the binary-compatibility-validator and dokka plugins.

The binary-compatibility-validator plugin applies itself to nested modules.
We don't want this.

The dokka plugin crashes on multi-module builds.
Kotlin/dokka#2954
swankjesse pushed a commit to cashapp/zipline that referenced this issue Jun 1, 2023
* Flatten Gradle modules

Nesting 'testing' inside 'zipline' and 'tests' inside 'zipline-kotlin-plugin'
make it difficult to use the binary-compatibility-validator and dokka plugins.

The binary-compatibility-validator plugin applies itself to nested modules.
We don't want this.

The dokka plugin crashes on multi-module builds.
Kotlin/dokka#2954

* Fixup paths in IoTestingCommon
@CLOVIS-AI
Copy link
Contributor

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

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.

@aajtodd
Copy link

aajtodd commented Jul 26, 2023

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

@IgnatBeresnev IgnatBeresnev added this to the Gradle runner 2.0 milestone Aug 17, 2023
@vmishenev
Copy link
Member

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.

hfhbd added a commit to sqldelight/sqldelight that referenced this issue Mar 27, 2024
hfhbd added a commit to sqldelight/sqldelight that referenced this issue Mar 27, 2024
* Remove outdated workaround for Kotlin/dokka#2954

* Update gradle.properties

---------

Co-authored-by: hfhbd <[email protected]>
hfhbd added a commit to sqldelight/sqldelight that referenced this issue Apr 2, 2024
* Remove outdated workaround for Kotlin/dokka#2954

* Update gradle.properties

---------

Co-authored-by: hfhbd <[email protected]>
@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