One of Kotlin's most attractive qualities, for me, is to be able to write code that I can use on the server side in my JVM setup, on the Android client side, and also on the web client side as JS. My big use cases are model classes, and code (calculations etc.) that works on them.
Is it possible to achieve this? IntellIj seems to want me to create either a Kotlin JS or Kotlin JVM module. First that means I can’t just mix in Kotlin code with my existing files, as I can do with Groovy, as I have to create the module in a new directory. And second I can’t generate both JVM and JS code from the same files. Unless I go symlinks - is that the recommended route?
I also tried using the Kotlin compiler from the command line through File Watchers, but hit issues with Windows not supporting the extremely long command line resulting from the CLASSPATH, which I have to include as the model classes have annotations from JPA and JSR-349 validations. Also, the approach feels a bit hacky, wouldn’t handle dependencies well, and I’d probably end up using a Makefile to sit alongside IntelliJ. I’d rather have a true IntelliJ solution if possible.