Hi! I have a multimodule multiplatform Gradle proj...
# gradle
g
Hi! I have a multimodule multiplatform Gradle project. All submodules are configured in the same way. Also some of them depend on other ones. I want to add examples to each module, so decided to add another JVM target (they allready have one) with name
example
. But when I just add the new target Gradle sync fails saying that each of
jvmMain
,
exampleMain
,
jvmTest
and
exampleTest
source sets can not determine which artifacts of dependency projects to use,
jvm
or
example
ones. How can I specify which target to depend on? Or how to "hide" some targets from depending on (and publishing)?
Also I thought out what other ways to provide examples there exist: 1. Creating addtional submodule for it is bad, because then there will be a lot of things of different concepts in it, so it will look like a garbage can. 2. Creating examples' mirror submodule for each existing submodule is a bit hassle. But it's not a bad variant. 3. I also thought about making my own target type (a copy of existing JVM target). But it's hard for me right now. Also in that case each
example
source set would depend on another
example
target instead of
jvm
one, which is not good but bearable.
t
@Anton Lakotka [JB] maybe you have some ideas?
a
How can I specify which target to depend on? Or how to "hide" some targets from depending on (and publishing)
You need to use disambiguation attribute: https://kotlinlang.org/docs/multiplatform-set-up-targets.html#distinguish-several-targets-for-one-platform But why do you need a separate target? while you can use separate Kotlin Source Set. Could you describe your need for "example" targets thoroughly?
g
Sorry, I didn't read Kotlin multiplatform documentation properly. I thought that I need a seperate Kotlin source set too, but didn't know that it's possible to create a source set without creating a target. Now I've found an answer. Sorry again and thank you!