when Kotlin Multiplatform projects are published t...
# community-support
a
when Kotlin Multiplatform projects are published to Maven there's a variant for each target. Each has a separate GAV coordinate and directory, and is linked together via the Gradle Module Metadata. The variants are discovered via a relative URL in the metadata. I want to emulate the same behaviour for a simple project, for an integration test. Something like
foo-lib
publishes text files to GAV
org.demo:foo-lib-text
and repo path
org/demo/foo-lib-text/
, and json files to
org.demo:foo-lib-json
with path
org/demo/foo-lib-json/
. The main variant is published to
org/demo/foo-lib/
. Is this possible? I tried adding feature variants but they use the same directory, but with a different directory.
okay, so digging into it, KGP uses an internal Gradle API, SoftwareComponentInternal to add custom
org.gradle.api.component.ComponentWithVariants
to a component. Gradle handles
ComponentWithVariants
specially here so they're published as variants in a different Maven repo directory, and linked to with a relative URL. It's pretty difficult to just quickly create a demo using these internal APIs, so I won't bother.
1
I actually did end up making a hacky demo https://gist.github.com/aSemy/8c3e248759dad5028623acc68e601a5d