P
P
Pavel Dunaev2019-04-27 20:31:17
gradle
Pavel Dunaev, 2019-04-27 20:31:17

How to combine frontend and backend in one kotlin multiplatform project?

I want to write a web application with a backend on kotlin under jvm and a frontend on kotlin-js. I configured multiplatform jvm + js in build.gradle. It compiles, but in build/classes/kotlin/js/main, but it should be in src/jvmMain/resources, so that later it can be added to jar. And I also did not understand how to add resources to the jar.

My build.gradle
plugins {
    kotlin("multiplatform") version "1.3.31"
}

repositories {
    mavenCentral()
    jcenter()
}

kotlin {
    jvm()
    js()

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
            }
        }

        jvm().compilations["main"].defaultSourceSet {
            dependencies {
                implementation(kotlin("stdlib-jdk8"))
                implementation("io.ktor:ktor-server-netty:1.1.4")
            }
        }
        
         // Не работает
         //js().compilations["main"].output.classesDirs.from("src/jvmMain/resources")
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dumitru Preguza, 2019-05-20
@dyma_pre

The answer is here: https://kotlinlang.ru/docs/reference/multiplatform.html

D
Denis Mashanov, 2017-03-26
@LoneRay

It turns out in search I forgot to write "top: 0;" :D Sergey
helped me with this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question