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

Mark Vogel

02/03/2023, 3:44 PM
When adding a dependency to
commonMain
that does not support a specific platform such as Kotlin/JS, how can I exclude the dependency from
jsMain
?
j

jw

02/03/2023, 4:31 PM
Add a nonJsMain source set, add it to all non-JS targets, and define it there?
m

Mark Vogel

02/03/2023, 4:32 PM
Could you give an example for accomplishing that?
Or perhaps point me to some documentation? I haven't been able to find much on how the multiplatform configurations work for that kind of thing
j

jw

02/03/2023, 4:34 PM
I didn't add any dependencies, but you would just put them into the source set like any other
m

Mark Vogel

02/03/2023, 4:38 PM
Awesome! Thanks. Do you have any insight on the conversion between the
sourceSetName { ... }
in Groovy to the Kotlin equivalent? Is that
val sourceSetName by creating { ... }
?
j

jw

02/03/2023, 4:38 PM
yes
or
create("sourceSetName") { }
to tone down their crazy DSL
m

Mark Vogel

02/03/2023, 4:40 PM
Awesome I'll see if I can make this work for my project Thanks!
j

John O'Reilly

02/03/2023, 6:22 PM
Had been meaning to do this as well for particular project....just tried it and works great! Thanks! https://github.com/joreilly/Confetti/pull/232/files#diff-cf9ae3b1eb7273a914f22b1e6d22d8447f88df0e7245a5b856fb751e507b979b
(in this case had dependency that was mobile specific that I didn't want pulled in for JVM)
5 Views