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

Resolution of platform dependencies fails the build with Kotlin 1.9 / Gradle 8 #3153

Closed
IgnatBeresnev opened this issue Sep 1, 2023 · 5 comments
Labels
bug runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin

Comments

@IgnatBeresnev
Copy link
Member

IgnatBeresnev commented Sep 1, 2023

Important

This issue was fixed in Dokka 1.9.10, so if you update to it, it should be gone. No additional flags are required in Dokka 1.9.10.

Problem

Due to a combination of reasons, Gradle builds might fail with one of the following problems:

Task ':redwood-treehouse:dokkaHtmlPartial' uses this output of task ':redwood-protocol-widget:transformIosMainCInteropDependenciesMetadataForIde' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

or

Cannot change dependencies of dependency configuration ':vclib-openid:iosMainImplementationDependenciesMetadata' after task dependencies have been resolved

Cause

It's difficult to pinpoint the exact reason for these errors as multiple factors contribute to it:

  • Kotlin 1.9.0 (likely some underlying change to implementationMetadataConfiguration in KGP)
  • Gradle 8
  • Usage of cinterop
  • kotlin.mpp.enableCInteropCommonization being set to true
  • Usage of Gradle's includeBuild

Depending on the combination, it will lead to one of the mentioned errors.

Workarounds

Unfortunately, the potential fixes were found late into testing Dokka 1.9.0. We did not want to make rushed decisions that could break unaffected projects, but we also did not want to delay the release even more, so we settled on providing workarounds in Dokka 1.9.0 that are disabled by default.

Important

This issue was fixed in Dokka 1.9.10, so if you update to it, it should be gone. No additional flags are required in Dokka 1.9.10.

There are three flags that change the way Dokka resolves platform dependencies. The flags are mutually exclusive, please try them in descending order (from top to bottom):

  • org.jetbrains.dokka.classpath.useNativeDistributionAccessor=true
  • org.jetbrains.dokka.classpath.useKonanDistribution=true
  • org.jetbrains.dokka.classpath.excludePlatformDependencyFiles=true - last resort, ignores platform dependencies altogether, so you might see Error class in signatures.

You can add these flags to your gradle.properties or pass them as a project property in CLI:

./gradlew -Porg.jetbrains.dokka.classpath.useNativeDistributionAccessor=true

Please, let us know if any of these workarounds (or especially all of them) didn't help.

Short-term solution

We aim to ship a well-tested solution that will be enabled by default in Dokka 1.9.10, likely some time in October.

Long-term solution

We're taking the necessary steps to resolve this problem for good (#3121) and to discover similar compatibility problems very much in advance, before our users experience them. We plan to implement it by Kotlin 2.0 / 2.1, but no later than the first Stable release of Dokka.

@JakeWharton
Copy link

The first property appears to have worked for Redwood. Thanks! I did not try the others.

IgnatBeresnev added a commit to IgnatBeresnev/ktor that referenced this issue Sep 1, 2023
Adds a workaround for running Dokka with Gradle 8 and Kotlin 1.9.0; otherwise it leads to build errors related to platform dependency resolution

For more details, see Kotlin/dokka#3153
charleskorn added a commit to batect/docker-client that referenced this issue Sep 2, 2023
@jeffdgr8
Copy link

The first property resolved the issue in my library as well. Thank you!

By the way, I believe you meant "try them in descending order".

e5l pushed a commit to ktorio/ktor that referenced this issue Nov 3, 2023
Adds a workaround for running Dokka with Gradle 8 and Kotlin 1.9.0; otherwise it leads to build errors related to platform dependency resolution

For more details, see Kotlin/dokka#3153
@AngeloFilaseta
Copy link

The first property worked for me too as a workaround. I was struggling very hard before finding this issue :(

marychatte pushed a commit to ktorio/ktor that referenced this issue Nov 10, 2023
Adds a workaround for running Dokka with Gradle 8 and Kotlin 1.9.0; otherwise it leads to build errors related to platform dependency resolution

For more details, see Kotlin/dokka#3153
@IgnatBeresnev
Copy link
Member Author

This problem was fixed in Dokka 1.9.10, so it no longer requires the flags mentioned above.

  • If you are using Dokka 1.9.10, you can remove the flags from your configs
  • If you are using Dokka < 1.9.0, I suggest you make the jump to 1.9.10, and the problem will be fixed without any additional flags.

Thanks to everyone who tested the solution and provided feedback! I'll close the issue now as we haven't seen any new reports about it recently, so hopefully it's all working as expected

@gosha212
Copy link

gosha212 commented Jan 28, 2024

Hi @IgnatBeresnev,
I still can reproduce the issue on my android project after upgrading to gradle 8.3 with dokka 1.9.10.
./gradlew dokkaDocJar does work for me, but the publish task fails with the following problem:

A problem was found with the configuration of task ':detox:dokkaJavadoc' (type 'DokkaTask').

  • Gradle detected a problem with the following location: '/Users/georgys/Workplace/Detox/detox-public/detox/android/detox/build/intermediates/compile_r_class_jar/release/R.jar'.

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

Here is the branch: https://github.com/wix/Detox/tree/5a63be0ce84ca17068a394b241d472968f61c1e7
How to reproduce:

cd detox/android
./gradlew publish -Dversion=999.999.999

Non of the workaround worked for me.

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

5 participants