Is it possible to make a library module that is pure Kotlin (without a target platform like JVM or JS), so that it can be consumed by any other Kotlin module?

Suppose you have a Kotlin multi-platform project targeting all posible targets. The codebase is large and you would like to split the common code into multiple modules. You don’t want to keep repeating all the compilation targets. They are irrelevant anyhow.

plugins {
  kotlin("multiplatform") //version "1.4.0-rc"

kotlin { 
    sourceSets["commonMain"].dependencies { 

    sourceSets["commonTest"].dependencies {

Gives an error:

 Please initialize at least one Kotlin target in 'common_module_1 (:common_module_1)'.
Read more

Not yet, but it will be possible in future after full migration to IR and klib format.


Do you know if there’s a timeline/roadmap/estimation to when that will be?

JB never gives the timeline, but I do not think it will be available in preview until late 2021 (this is strictly my personal feeling, I do not have any inside information on this).

1 Like

Thanks. I understand why they don’t want to make promises, but it’s still very nice to have a very broad idea of what can be expected and what is unreasonable.

1 Like

Thanks for this! It allows me to plan developments to our code base better.

1 Like