I have updated Kotlin version to 1.7.0 in my libra...
# multiplatform
a
I have updated Kotlin version to 1.7.0 in my library, and when I publish it, everything works fine. However, using the library from another multi-platform project, I can’t access the common source set. If I downgrade to Kotlin 1.6.10, and publish it again (with a different version), I can access the common source set from the other project. Is there something has changed in 1.7.0 that I’m not aware of? Or is it somehow not related to the Kotlin version? More info in the thread.
1
t
I believe 1.7.x libraries are only consumable by applications also on 1.7.x
a
@Trevor Stone I’m using Kotlin 1.7.0 in both projects.
t
Potentially https://kotlinlang.org/docs/multiplatform-hierarchy.html? There was a change in default behavior between 1.6.10 and 1.6.20
a
Okay, I assume it is enabled by default for projects and libraries that are using version 1.7.0, correct? When adding this flag to the library:
Copy code
kotlin.mpp.enableCompatibilityMetadataVariant=true
Gradle sync works fine. However, when I publish to mavenLocal, i get this error:
Copy code
> Could not resolve all files for configuration ':kamel-core:metadataCompileClasspath'.
      > Could not resolve org.jetbrains.compose.ui:ui:1.2.0-alpha01-dev753.
When adding this flag to the project:
Copy code
kotlin.mpp.hierarchicalStructureSupport=false
Gradle sync fails with this error:
Copy code
kotlin.UninitializedPropertyAccessException: lateinit property targets has not been initialized
	at org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.getTargets(KotlinMultiplatformExtension.kt:25)
What am I missing?
m
I looked at Kamel and I think its because your only publishing a jvm() sourceset, with no other sourceSets like android().
You can take a look at one of my forks for an example of setting up a compose library for Jvm and Android https://github.com/Syer10/compose-material-dialogs
a
@Mitchell Syer If you see the images I have attached, they include android and desktop source sets. Meaning, I can use the library code from the android and desktop source sets (including the modules). The problem is with the
commonMain
source set, I can’t access the library from there with Kotlin version 1.7.0
t
Can you post your gradle.properties file
a
For library:
Copy code
kotlin.code.style=official
android.useAndroidX=true
kotlin.mpp.stability.nowarn=true
kotlin.mpp.enableCompatibilityMetadataVariant=true
For project:
Copy code
kotlin.code.style=official
android.useAndroidX=true
#kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.stability.nowarn=true
org.gradle.jvmargs=-Xmx4096m
kotlin.mpp.hierarchicalStructureSupport=false
m
@Ali Albaali I meant for Kamel-core, I think because it only uses jvm() that it cant be used for projects that use both jvm() and android() because it doesnt provide the required metadata
It probably worked fine for projects without HMPP because it was much simpler, HMPP is smarter/more advanced
t
It looks like the library is just android and desktop though right, so just supporting jvm would be fine
to the initial question because I think I focused on the wrong thing "I have updated Kotlin version to 1.7.0 in my library, and when I publish it, everything works fine. However, using the library from another multi-platform project, I can’t access the common source set."
It syncs correctly but then when you are trying to consume it, code isn't accessible?
a
@Mitchell Syer I understand. I should’ve mentioned that, using the kamel-core module works fine. I can access everything from it (e.g. Resource, KamelConfig, etc…). The problem is with kamel-image module, I can’t access lazyPainterResource or KamelImage composables from commonMain source set.
@Trevor Stone Yes, the library supports only android and desktop. If you check this link, you can see everything is uploaded correctly.
m
I was noticing that with my project as well, it uses Kamel and it builds fine, but the ide cant find anything in Kamel
a
@Trevor Stone Only the code from
kamel-image
commonMain source set isn’t accessible. The code from
kamel-image
module with androidMain and desktopMain is accessible and working fine.
t
in your project consuming the library how are you defining the dependencies
a
Copy code
val commonMain by getting {
    dependencies {
        api(compose.runtime)
        api(compose.foundation)
        api(compose.material)
        api(compose.material3)
        api(compose.materialIconsExtended)
        implementation(project(":data"))
        api("org.jetbrains.kotlinx:kotlinx-datetime:0.3.3")
        api("com.alialbaali.kamel:kamel-image:0.4.21")
        api("com.halilibo.compose-richtext:richtext-commonmark:0.10.0")
    }
}
t
why is
kotlin.mpp.hierarchicalStructureSupport=false
in your project
a
I tried to disable it to see if it works. It wasn’t there before.
You can try to create new project by using the default template, add the library, and you’ll see the problem is there.
a
I am also having this very same problem. I have battled with it all night, to no avail
t
I tired playing with it more last night and was able to build the project with code in the common source set, but the IDE wouldn't resolve correctly and showed errors
a
@Trevor Stone does it show the
kamel-image
commonMain package in the “External libraries” view?
It does build without any errors, so I think the problem is with Kotlin IDE plugin, it is not identifying the commonMain source set.