Given a multiplatform (JVM) module that depends on...
# multiplatform
z
Given a multiplatform (JVM) module that depends on another multiplatform library (JVM, Android, iOS); can I depend on this from a "pure" kotlin library module somehow? It doesnt really make sense, just trying to learn where the boundaries are.
Ultimately, not beng able to do this results in me making modules that dont "need" to be multiplatform .. multiplatform.
j
What does pure mean
z
Copy code
plugins {
    id 'kotlin'
}
Just this ^, no multiplatform targets, etc.
j
Don’t know what it does, I guess it is just JVM?
z
🤦🏽‍♂️ Apparently "pure" can depend on a multiplatform module .. at least with JVM specified as one of the targets. I just set it up incorrectly a number of times and thought it wasnt possible.
j
if the kotlin id plugin is at the end the jvm one and all kmp modules include jvm then it works
z
That actually makes sense!
j
you can do a quick check by commenting the jvm target on one of them and checking if it compiles
z
It does not 👍🏽
b
There's currently no such thing as "pure" kotlin modules. CommonMain target is just a metadata sourceSet that demands a target set definition and is bound by it.
👍 1
So if you have a kmp lib that supports jvm, js and linuxX64, you can use it in a module with just jvm target or jvm + linuxX64 or any other permutations of the three targets (at the commonMain sourceSet). However you could not use it in the module that targets iosArm64 for example nor a module that targets jvm, js and mingwX64 (since the library does not support mingw).
👍 1
Note that you can still use the lib at supported target sourceSets if your module has some unsupported targets (e.g. lib defined on linuxX64 sourceSet instead of commonMain from the last example above would work)
z
That makes perfect sense too, and is inline with how my mental model of it looks 👍🏽 Most likely "pure" is a pretty bad word for it - I simply mean a "kotlin library" without any of the multiplatform stuff, i.e. just "main" sourceSets, no "commonMain", etc. My conclusion from this is what Javier mentioned above - that running a kotlin library will depend on where you run it? In my case it boils down to the JVM.
b
That would then be the same as multiplatform library with only jvm target from a Library consumer perspective
z
Also, Im not sure if it actually matters whether something is "just" a kotlin library, as compared to multiplatform (with just common sourceset) but I imagine the build times will be lower in the former