https://kotlinlang.org logo
#build-tools
Title
# build-tools
m

Marc Knaup

05/09/2019, 2:11 PM
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

h0tk3y

05/27/2019, 4:31 PM
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

Marc Knaup

05/27/2019, 4:32 PM
oh wow that's wild, thanks
h

h0tk3y

05/27/2019, 4:37 PM
We didn't. This bug is now tracked as https://youtrack.jetbrains.com/issue/KT-31641
🙏 2
k

Kirill Zhukov

08/09/2019, 12:27 AM
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

plastiv

08/14/2019, 8:53 AM
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))
        }
    }
}
3 Views