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

Adding ktlint to multiplatform modules breaks their jvm (gradle project) consumers #581

Closed
bnvinay92 opened this issue May 3, 2022 · 1 comment

Comments

@bnvinay92
Copy link

bnvinay92 commented May 3, 2022

Adding the ktlint gradle plugin to a multiplatform module breaks kotlin jvm consumers (./gradlew :java-consumer:build) with:

Could not determine the dependencies of task ':java-consumer:test'.
> Could not resolve all task dependencies for configuration ':java-consumer:testRuntimeClasspath'.
   > Could not resolve project :kmp-producer.
     Required by:
         project :java-consumer
      > The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :kmp-producer:
          - jvmRuntimeElements
          - ktlint
        All of them match the consumer attributes:
          - Variant 'jvmRuntimeElements' capability ktlint-repro:kmp-producer:unspecified declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Unmatched attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
          - Variant 'ktlint' capability ktlint-repro:kmp-producer:unspecified declares a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

This can be fixed by converting the consuming module to multiplatform as well, but adding the jvm { withJava() } target to it causes ktlint to be added to the runtimeClasspath (./gradlew :kmp-consumer:dependencies):

runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
+--- project :kmp-producer
|    \--- com.pinterest:ktlint:0.42.1
|         +--- com.pinterest.ktlint:ktlint-core:0.42.1
|         |    +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.20
|         |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.20 -> 1.6.21
|         |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
|         |    |    |    \--- org.jetbrains:annotations:13.0
|         |    |    +--- org.jetbrains.kotlin:kotlin-script-runtime:1.5.20
|         |    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.5.20
|         |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.20 -> 1.6.21 (*)
|         |    |    +--- org.jetbrains.kotlin:kotlin-daemon-embeddable:1.5.20
|         |    |    \--- org.jetbrains.intellij.deps:trove4j:1.0.20181211
|         |    +--- org.ec4j.core:ec4j-core:0.3.0
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21
|         |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.21 (*)
|         |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
|         |              \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-reporter-baseline:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-reporter-checkstyle:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-reporter-json:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-reporter-html:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-reporter-plain:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-reporter-sarif:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    +--- io.github.detekt.sarif4k:sarif4k:0.0.1
|         |    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0
|         |    |    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.1.0
|         |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.30 -> 1.6.21 (*)
|         |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.4.30 -> 1.6.21
|         |    |    |         \--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.1.0
|         |    |    |              \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.1.0
|         |    |    |                   +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.30 -> 1.6.21 (*)
|         |    |    |                   \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.4.30 -> 1.6.21
|         |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.31 -> 1.6.21 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-ruleset-experimental:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-ruleset-standard:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- com.pinterest.ktlint:ktlint-ruleset-test:0.42.1
|         |    +--- com.pinterest.ktlint:ktlint-core:0.42.1 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
|         +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.20 (*)
|         +--- com.github.shyiko.klob:klob:0.2.1
|         +--- info.picocli:picocli:3.9.6
|         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 -> 1.6.21 (*)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 (*)

Reproduced here: https://github.com/bnvinay92/ktlint-repro with using ktlint 10.2.1. Seems related to #571 except this uses the kotlin("jvm") plugin as well.

@bnvinay92 bnvinay92 changed the title Adding ktlint breaks java modules consuming multiplatform modules Adding ktlint to multiplatform modules breaks their java (gradle project) consumers May 3, 2022
@bnvinay92 bnvinay92 changed the title Adding ktlint to multiplatform modules breaks their java (gradle project) consumers Adding ktlint to multiplatform modules breaks their jvm (gradle project) consumers May 3, 2022
@JLLeitschuh
Copy link
Owner

I believe this was fixed #571

If not, PR to fix the issue, with a test would be accepted. 🙂

RBusarow added a commit to square/workflow-kotlin that referenced this issue May 6, 2022
This contains a fix for runtime classpath issues in KMP modules with JVM consumers. JLLeitschuh/ktlint-gradle#581
RBusarow added a commit to square/workflow-kotlin that referenced this issue May 6, 2022
This contains a fix for runtime classpath issues in KMP modules with JVM consumers. JLLeitschuh/ktlint-gradle#581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants