Fullstack Kotlin with Maven?

Hello, everybody.

I’d like to get my team to use Kotlin Multiplatform as we could share a lot of code, but I’ve encountered some obstacles myself that make it impossible to work with it effectively at the moment.
I would be grateful for a little discussion about possible best practices and caveats with our current setup!

We currently use a JVM-backend, which serves as an HTTP server, similar to Ktor. The frontend is a simple vue-app written in Typescript.

Contrary to the examples and Gradle templates, these are not two projects:
Our bundled fullstack app is one fat JAR.
How would you structure your Maven project, then?
The current setup is as follows:

|- pom.xml
|- package.json
|- src
|- resources (we want our frontend here!)

The “assemble” module will build the frontend and put it inside the backend/resources folder (as we cannot do this inside the root module).
This kinda works, but it’s not as smooth as Gradle:

  • How would you handle auto/hot-reload? File watchers with “compile-on-save” are quite cumbersome.
  • Where do you declare frontend dependencies, inside the package.json or in the pom.xml?
    Both options exclude some features; a dependency inside package.json will not be detected by Kotlin, a dependency inside pom.xml will not put the package inside node_modules. One solution would be to declare it in both, but why the redundancy?
    Nevertheless, I was not able to import the kotlinx.html package as the browser was complaining about missing scripts. Is it necessary to declare the dependency in the index.html as well?

The current workflow with Kotlin Multiplatform and Maven is extremely confusing and not as flexible and smooth as I’d like. But maybe I’m just missing something. :slight_smile:

Kotlin MPP only supports Gradle: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html. We don’t plan to add Maven support currently.