Multiplatform projects: common to common dependency

I am working on a sample project to demonstrate multiplatform projects, but am currently stuck on getting a common module to depend on another common module. See example here:

IntelliJ IDEA thinks I have it configured just fine, autocomplete works and no errors are highlighted. However, when I run “gradle test”, it is as if one common module can not see another, even though the dependency is explicit in the build.gradle file.

Has anybody gotten this to work? I am trying to puzzle out if this a misconfiguration of gradle, an unsupported feature, or a bug.

Looking at your project you are using the 1.2.71 plugin. This plugin has some limitations in transitive dependencies. In other words, your platform implementation modules need to depend on platform implementation modules for the “generic” bit. You don’t have such a module. Think of it this way, a common module is just a container for source, it does not actually do any compilation. Platform modules just import the source code, add their platform specific code and the whole source set is compiled for the target platform. It is not that different from not using multi-platform code that imports a source directory from shared folder (except that Intellij doesn’t like file aliasing)

1 Like

Well the 1.2.71 plugin seems to be the latest release version, which is why I am using it. Looks like there is a 1.3.0 version on the horizon, so I will try again when that is released.

I did know that common modules have to be compiled in terms of the platform or regular module depending on them. The surprise was that the dependency is not deducible transitively.

Based on your comment, I fixed this by adding
expectedBy project(“:common-generic”)
to the platform modules that transitively pull in common-generic, which does appear to work.

It made me wonder if the comnon-to-common dependencies were still necessary.
compile project(“:common-generic”)
I tried deleting them and it turns out that they are still required.

Thanks for looking into it and taking the time to respond. I don’t know how long it would have taken me to start questioning whether or not transitive dependencies were supported for common modules.