In Kotlin’s 1.6.20 default hierarchical project structure, what are all the predefined intermediate ...
j
In Kotlin’s 1.6.20 default hierarchical project structure, what are all the predefined intermediate source sets? The docs talk about
iosMain
but not others. Are there more predefined ones?
m
There’s not really any docs that I’ve found that lay all of them out. The basic way to figure out what source sets get created for you is that any target you add (e.g.
ios()
,
jvm()
,
android()
) will create a matching
<target>Main
and
<target>Test
source set that depends on the matching
common
sourceset. e.g.
iosMain/Test
,
jvmMain/Test
,
androidMain/Test
There are a few small “buts” with this to be aware of which is that the
ios()
target (and others) is a shortcut for several ios targets (listed here) so in addition to the umbrella
iosMain/Test
source set you get a sourceset pair for each of those actual targets,
iosArm64Main/Test
etc for things that are specific to a particular arch. But as with other sourcesets you dont need to have source directories for these if you dont need them
You can also look at
File -> Project Structure -> Modules
in intellij to see what source sets your project has, including ones that are generated but not used
j
I wish Android Studio could show that
m
In Android Studio if you right click on the src folder and pick new -> Directory you get a dialog with all the different directories that match a source set that do not already exist.
👌 1
m
Could make your own plugin to use for every project so you get the same exact setup in every module. For Example: https://github.com/05nelsonm/kotlin-components/blob/876783319c9a25cf6e3faea4dcd4f2[…]o/matthewnelson/kotlin/components/kmp/KmpConfigurationPlugin.kt
j
Yes I have my own convention plugin but I thought that when the kotlin docs mentioned
default hierarchical project structure
here it meant that by default there was already preconfigured a sourceset graph similar to the one you posted.
m
Ah. I took it as "no project uses defaults and that gradle property is always set so lets make it the default"
j
It seems no
jvmCommon
sourceset exists by default.
m
It seems no
jvmCommon
sourceset exists by default
IKR? It's weird. I do have issues with a
jvm
+
android
kmm project when publishing to MavenCentral. Have to build and publish
jvm
only, then build
jvm
+
android
and publish
android
only. JavaDocs aren't produced for
-jvm
if you build
jvm
+
android
, but that's it.