Hello All — Happy to be part of this community! W...
# getting-started
g
Hello All — Happy to be part of this community! We’re beginning to adopt Kotlin as our backend language and our intermediate language for datamodels/common configuration/constants. Maybe I can be redirected to the right channel. I’m trying to setup either a multiproject build or a composite build which allows me to transpile several of our datamodels into javascript and to the jvm. I’m currently blocked by the js project depending on a jvm project but disliking it. Finding documentation has been a tough because there’s so many outdated repositories and tutorials out there across gradle versions and kotlin versions. (The kotlin docs could use a version selector so we aren’t given so many caveats about crazy version matrices.) My current error is this
Copy code
Could not determine the dependencies of task ':models-js:compileKotlinJs'.
> Could not resolve all task dependencies for configuration ':models-js:compileClasspath'.
   > Could not resolve project :models.
     Required by:
         project :models-js
      > Unable to find a matching variant of project :models:
          - Variant 'apiElements' capability com.gigwell.shared.models:models:1.0:
Can someone recommend a recently updated project (hopefully on 1.3.61+) and Gradle 5/6 that demonstrates this? The closest I found is kotlin-todomvc but its still using
Copy code
"org.jetbrains.kotlin.frontend"
Cheers
s
Hi! I know this sounds silly but have you defined the gradle plugin in the root build gradle?
Copy code
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
g
Yes, I have the root project able to initiate the build, and successfully build the first module (jvm targeted) - when it gets to the second module, it breaks. I think how I’ve defined the first module is blocking the js module from consuming it? Structure is
Copy code
* Shared
   * buildSrc (Just versions, after reading some posts here, this probably will go away for us.)
   * models (jvm)
   * models-js (js)
r
models should be common (not jvm, nor js)
g
I found this project - https://github.com/svok/kotlin-multiplatform-sample which has a similar setup where they have a proj-common that is multi-platform, and then they have a backend / jvm and front end / js. To create the ‘common’ layer, do I need to configure each of the consuming targets, jvm, js?
Copy code
plugins {
    kotlin("multiplatform")
}
...
kotlin { jvm() {...} js() {...} }

?
r
You can take a look at https://github.com/rjaros/kvision-examples/tree/master/addressbook-fullstack-ktor This project is using some KVision specific task configuration, but the layout and config should be universal.
g
Thanks robert
r
The project you've found is using old multiplatform layout (with gradle subprojects)
Mine is using new MPP and new kotlin-js plugin.
g
Thanks, this is exactly what I’m after.
KVision looks pretty sweet. Thanks again for the suggestion. Struggled to get a mimic of this working, but ended up being related to Intellij Caches. Invalidate and Restart for the win? (🤦‍♂️ )
😬 2
m
You can have a look at this multi-platform example, using Kotlin JS+JVM: https://github.com/hexagonkt/real_world It uses the hexagon framework, but you can look how gradle is configured there. (RealWorld is a project collecting various example implementations of the same app in a moltitude of languages, both front-end and back-end)
👍 1