Multiplatform module dependencies added as gradle jars to classpath

I have a gradle project with two multiplatform library modules, which depend on each other. Let’s call them library1 and library2, library2 has a implementation compile time dependency on library1.

Another module, let’s call it java-project, has a compile time dependency on both library1 and library2.

If I import this setup into IntelliJ IDEA, both libraries are added to java-project’s classpath as a single entry, referencing the two jars as they would be created by gradle! There are no module dependencies created. Obviously, the jars don’t exist unless the modules are built by gradle.

I have created a minimal demo that show-cases this problem.

In this minimal project, I can remove the dependency to library1 to solve the problem. Then, both libraries will be added to the compile classpath, even though library2 lists library1 in the implementation configuration, meaning it should not be exported to dependent projects.

However, this is not possible in my real-life project, where intermodule dependencies are more complex.

Is this an IDEA bug, or am I missing something here?

Related issue: KT-28895