Multiplatform project with multiple common modules

I need help with getting a simple demo project compiling. The project consists of 2 layers of modules that depend on each other. Each layer consists of 3 modules: common, jvm, js.

For better illustration, I created a small dependency graph of my modules:

modules

The whole project can be found on github, too:

I try to build the project via gradle with the following command:

cd multiplatformdemo/multiplatformdemo/
./gradlew build

And gradle will return the following failure:

e: /…/DemoCommon.kt: (3, 8): Unresolved reference: dependency
e: /…/DemoCommon.kt: (7, 21): Unresolved reference: DependencyCommon

FAILURE: Build failed with an exception.

Any help is much appreciated.

You forgot to add

compile project(":dependency-js")

to your demo-js module :wink:

Damn, thanks for pointing that out.

Unfortunately I didn’t do this particular mistake in my actual bigger project, in which it still does not compile. I will need time to compare the projects. Thanks so far!

I now added the kotlin file DemoJs.kt within the js platform module demo-js. As far as I can tell, it is correctly compiled into the demo-js.js output. My problem is that this output is not including the kotlin code from the dependency-common module.

How am I supposed to build the demo-js module, such that its output does not only include the compilation of its own kotlin code, but also the compilation of the kotlin code within dependency-common module?

I am starting to assume that I will need to handle this within my gradle script myself (copy the output of the dependency module). Is there any better way?