Hi there,
If I am not mistaking, Kotlin MPP was not design with this use case in mind and you might not be able to achieve what you are looking for with it. See this forum post for more info.
Common code must be pure kotlin code, without any kind of platform SDK available, so unless you interface the Java SDK with expect/actual semantic you wont be able to use them.
Another way would be to have multiple gradle projects, a shared one containing your code that will be able to use the Java SDK and two others for your Forge and Fabric mod loaders that will use the shared one. This might be your best option in my opinion
Hope this helps.