I have an existing Kotlin project, consisting of a multi-module setup with Gradle, using multi-project builds described here: Structuring and Building a Software Component with Gradle
This works pretty good in modularising and sharing our code.
However, we want to start adding a JS module to it and share some common code, so preferably in the same directory structure we have now:
root:
- build.gradle.kts // root Gradle script
- server
- src/main/kotlin
- src/test/kotlin
- build.gradle.kts
- export
- src/main/kotlin
- src/test/kotlin
- build.gradle.kts
- ...etc, more modules
So I thought of just adding a new module and have it use the kotlin("multiplatform") plugin and use the commonMain/commonTest directories and stdlib-common dependency.
However, I am unable to include these projects in our other modules like a do with my other project by doing:
dependencies {
implementation(project(":common"))
}
It complains that :common can not be found.
I tried adding source-sets of common to my other modules, but no luck.
Is there a way to add a Kotlin-common module to an already existing multi-module setup?
EDIT:
Well, that was simple, and pretty obvious.
I forgot to add a JVM and JS compilation into my common-project. It works great now.