Hey guys, does anybody know why I get the followin...
# build-tools
m
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 exampleskaptKotlin`:
Using them triggers a warning when publishing:
Copy code
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
h
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:
Copy code
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
oh wow that's wild, thanks
h
We didn't. This bug is now tracked as https://youtrack.jetbrains.com/issue/KT-31641
🙏 2
k
Having similar issue:
Copy code
> 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…
Copy code
> 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
I think Sergey Igushkin hints into right direction. This snippet seems to made the trick for me:
Copy code
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))
        }
    }
}