I have a multiplatform project and it contains 3 m...
# multiplatform
a
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
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
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
have you considered breaking this up into separate projects?
a
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
if you are publishing to Maven, the dependencies should be handled for you. are you saying you want a fat jar?
a
Exactly
It only builds the jars of the current module without using any dependencies or code from the other modules
k
yes that's normal. there are plugins for building fat jars.
a
Like shadow jar right?
k
yep