m

    Marc Knaup

    3 years ago
    Hey guys, does anybody know why I get the following error when I remove either the
    exclude
    or the
    attributes
    block from my dependencies?https://github.com/fluidsonic/fluid-json/blob/master/annotation-processor/build.gradle.kts#L18 `./gradlew :fluid-json-examples:kaptKotlin`:
    Using them triggers a warning when publishing:
    Maven publication 'default' contains dependencies that cannot be represented in a published pom file.
      - com.github.fluidsonic:fluid-stdlib-jvm:0.9.4 declared with Gradle attributes
    h0tk3y

    h0tk3y

    3 years ago
    I guess the
    kapt
    configuration misses the attributes to choose the appropriate variant of the MPP library (it definitely needs the
    jvm-runtime
    one). As a workaround, you can set the attribute on the configuration, not the dependency:
    configurations.getByName("kapt") {
        attributes.attribute(Usage.USAGE_ATTRIBUTE, objects().named(Usage::class.java, "java-runtime"))
    }
    Let me check if we have this in the issue tracker.
    m

    Marc Knaup

    3 years ago
    oh wow that's wild, thanks
    h0tk3y

    h0tk3y

    3 years ago
    We didn't. This bug is now tracked as https://youtrack.jetbrains.com/issue/KT-31641
    k

    Kirill Zhukov

    3 years ago
    Having similar issue:
    > Cannot choose between the following variants of com.squareup.wire:wire-runtime:3.0.0-rc01:
      - jvm-api
      - jvm-runtime
      - metadata-api
    In this case I need
    jvm-runtime
    but I think setting that in configuration messes up Dagger configuration in the same module somehow…
    > Unable to find a matching variant of com.google.dagger:dagger-compiler:2.24:
      - Variant 'compile' capability com.google.dagger:dagger-compiler:2.24:
          - Incompatible attribute:
              - Required org.gradle.usage 'jvm-runtime' and found incompatible value 'java-api'.
    Also, somewhat related question, is Gradle reading
    "java-runtime"
    same as
    "jvm-runtime"
    ?
    I’m not seeing
    "java-runtime"
    in Usage 🙂
    I’m on Gradle 5.5.1
    p

    plastiv

    3 years ago
    I think Sergey Igushkin hints into right direction. This snippet seems to made the trick for me:
    subprojects { subProject ->
        subProject.configurations.all { configuration ->
            // Workaround for kapt bug with MPP dependencies
            // <https://youtrack.jetbrains.com/issue/KT-31641>
            // <https://youtrack.jetbrains.com/issue/KT-33206>
            if (name.contains('kapt')) {
                attributes.attribute(Usage.USAGE_ATTRIBUTE, subProject.objects.named(Usage.class, Usage.JAVA_RUNTIME))
            }
        }
    }