I'm coding a play!framework application, and use k...
# multiplatform
h
I'm coding a play!framework application, and use kotlin for a large portion of data classes and the like used both on the server and on the client. Compiling for two.platforms is now the easy part, yay! Can anyone point me to a play! example with kotlin multiplatform in it?
j
If I read the page right, the Play! framework seems to use the JVM for everything. In that case, you are not using the Kotlin multiplatform feature at all - this probably isn’t the channel you’re looking for. You’d just use normal Kotlin.
h
No, the server supplies javascript to the client. And this portion of javascript will be far more easy to maintain when it's actually kotlin while I code it... so I compile a library to both jvm and js for the play!framework to use. Question is: how do I get play! to forward the js from an imported dependency out to the client browsers?
j
Ah, OK. Well, it sounds like you’d just use a Kotlin MPP just as usual. You could add a Gradle task to copy the resulting compiled JS into whatever directory you need to be served up. I’ll get you some links; hopefully though someone will have experience with your platform in particular.
https://github.com/kropp/kotlin-multiplatform-sample And probably add a task to the JS platform’s build script, something like this:
Copy code
task deploy (dependsOn: kotlin2js){
    copy {
        from "build/wherever-your-output-is"
        into "path-where-you-want-it-to-go"
        include "*.js"
    }
}
h
Well, making an MPP is the easy part. And I don't want gradle to put sources anywhere, as I publish this via Maven and then import the libraries from there (both to the play! project and to other places). The difficulty was making Play! extract the javascripts from a dependency jar in order to distribute to clients... But I guess after all this question isn't really kotlin related. I could post it in random, I guess, or go to some Play! forum. Thanks for your efforts, anyway.