https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Ali Albaali

02/07/2021, 6:51 PM
I have a multiplatform project and it contains 3 modules desktop(jvm), commonJvm and android. When I try to run
PublishKotlinMultiplatform
task, I get this error:
Execution failed for task ':kamel-core:generateMetadataFileForKotlinMultiplatformPublication'.
> Invalid publication 'kotlinMultiplatform':
- Variants 'commonJvmApiElements-published' and 'desktopApiElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
- Variants 'commonJvmRuntimeElements-published' and 'desktopRuntimeElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
Anyone has an idea how to fix it?
k

Kris Wong

02/08/2021, 2:09 PM
i'm not 100% sure, but I suspect that combination of targets is not supported well in the same project
specifically, I see "Sharing code between JVM and Android" on the roadmap as postponed for later
a

Ali Albaali

02/08/2021, 2:14 PM
Yeah IDE support is pretty bad for shared jvm code. However the code compiles and everything is fine. The problem is I'm trying to publish only two targets which depend on JVM target. So far I've did some workarounds and it's kinda working. But I'm trying to look for more robust solution by disabling publication for the whole JVM target and only allow it for the others.
k

Kris Wong

02/08/2021, 2:18 PM
have you considered breaking this up into separate projects?
a

Ali Albaali

02/08/2021, 2:28 PM
Yeah i think that way would be possible to include the project as a separate dependency, but it also means I need to move the common code with it since jvmMain depends on it. But I'm not sure yet if I want to do it that way yet. Thanks tho.
Well now I've done that and everything is great except one thing, which is maven doesn't include the dependencies when building the jar, I've tried many solutions but none of them worked.
k

Kris Wong

02/08/2021, 9:09 PM
if you are publishing to Maven, the dependencies should be handled for you. are you saying you want a fat jar?
a

Ali Albaali

02/08/2021, 9:17 PM
Exactly
It only builds the jars of the current module without using any dependencies or code from the other modules
k

Kris Wong

02/08/2021, 9:41 PM
yes that's normal. there are plugins for building fat jars.
a

Ali Albaali

02/08/2021, 9:44 PM
Like shadow jar right?
k

Kris Wong

02/08/2021, 9:54 PM
yep
3 Views