soywiz-archive / klock

Multiplatform Date and time library for Kotlin
https://korlibs.soywiz.com/klock/
Creative Commons Zero v1.0 Universal
676 stars 51 forks source link

Metadata issue #55

Closed dhakehurst closed 5 years ago

dhakehurst commented 5 years ago

Hi, I think use of metadata is the right way to go. However, there seems to be an issue, I am depending on klock (transitively) via other libs of mine. And I get this error, not sure why the android libs are getting in the way?

Execution failed for task ':myModule:compileJava'.
> Could not resolve all files for configuration ':myModule:compileClasspath'.
   > Could not resolve com.soywiz.korlibs.klock:klock:1.5.0.
     Required by:
         project :myModule > project :myModule-api > myGroup:otherModule-api:3.1.0-SNAPSHOT > myGroup:otherModule-api-jvm8:3.1.0-SNAPSHOT
      > Cannot choose between the following variants of com.soywiz.korlibs.klock:klock:1.5.0:
          - android-debugApiElements
          - android-debugRuntimeElements
          - android-releaseApiElements
          - android-releaseRuntimeElements
          - jvm-api
          - jvm-runtime
        All of them match the consumer attributes:
          - Variant 'android-debugApiElements' capability com.soywiz.korlibs.klock:klock:1.5.0:
              - Unmatched attributes:
                  - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
                  - Required org.gradle.dependency.bundling 'external' but no value provided.
                  - Required org.gradle.jvm.version '8' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'androidJvm' but wasn't required.
              - Compatible attribute:
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
          - Variant 'android-debugRuntimeElements' capability com.soywiz.korlibs.klock:klock:1.5.0:
              - Unmatched attributes:
                  - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
                  - Required org.gradle.dependency.bundling 'external' but no value provided.
                  - Required org.gradle.jvm.version '8' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'androidJvm' but wasn't required.
              - Compatible attribute:
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime'.
          - Variant 'android-releaseApiElements' capability com.soywiz.korlibs.klock:klock:1.5.0:
              - Unmatched attributes:
                  - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
                  - Required org.gradle.dependency.bundling 'external' but no value provided.
                  - Required org.gradle.jvm.version '8' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'androidJvm' but wasn't required.
              - Compatible attribute:
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
          - Variant 'android-releaseRuntimeElements' capability com.soywiz.korlibs.klock:klock:1.5.0:
              - Unmatched attributes:
                  - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
                  - Required org.gradle.dependency.bundling 'external' but no value provided.
                  - Required org.gradle.jvm.version '8' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'androidJvm' but wasn't required.
              - Compatible attribute:
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime'.
          - Variant 'jvm-api' capability com.soywiz.korlibs.klock:klock:1.5.0:
              - Unmatched attributes:
                  - Required org.gradle.dependency.bundling 'external' but no value provided.
                  - Required org.gradle.jvm.version '8' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
              - Compatible attribute:
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-api-jars'.
          - Variant 'jvm-runtime' capability com.soywiz.korlibs.klock:klock:1.5.0:
              - Unmatched attributes:
                  - Required org.gradle.dependency.bundling 'external' but no value provided.
                  - Required org.gradle.jvm.version '8' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
              - Compatible attribute:
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime-jars'.
dhakehurst commented 5 years ago

I think I have solved the issue,

I was trying to use the kotlin generated libs from a pure java project.

it is necessary to add the

"attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)"

to the dependency configuration in order to disambiguate between the different options

AdibaM commented 5 years ago

Can you post your build.gradle file

dhakehurst commented 5 years ago

I can't, but I think this should have the answer,

https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#disambiguating-targets

eugenio1590 commented 4 years ago

I get the same error, but I cannot apply "attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)" to the "com.soywiz.korlibs.klock:klock" dependency because I have configured the multiplatform project to use the Js variant.

This is not a problem when I compile the project but currently, I am using liquibaseRuntime, so I think this could be the problem.

eugenio1590 commented 4 years ago

I fixed this changing the "com.soywiz.korlibs.klock:klock" dependency to compileOnly.

compileOnly("com.soywiz.korlibs.klock:klock:$klockVersion")