Skip to content

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

@IgnatBeresnev

Description

@IgnatBeresnev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions