Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-7962 Fix fullstack-mpp sample #209

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 0 additions & 86 deletions fullstack-mpp/build.gradle

This file was deleted.

83 changes: 83 additions & 0 deletions fullstack-mpp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.*
Fixed Show fixed Hide fixed

Check warning

Code scanning / detekt

Wildcard imports should be replaced with imports using fully qualified class names. Wildcard imports can lead to naming conflicts. A library update can introduce naming clashes with your classes which results in compilation errors. Warning

org.jetbrains.kotlin.gradle.targets.js.webpack.* is a wildcard import. Replace it with fully qualified imports.

plugins {
id("org.jetbrains.kotlin.multiplatform") version "2.1.0"
}

kotlin {
targets {
js("frontend", IR) {
browser {
testTask {
// TODO: disable browser tests since we can"t run it on teamcity agents yet
Dismissed Show dismissed Hide dismissed
enabled = false
}
webpackTask {
mainOutputFileName = "output.js"
}
binaries.executable()
}
}
jvm("backend") {
}
}

sourceSets.forEach {
it.dependencies {
implementation(project.dependencies.enforcedPlatform("io.ktor:ktor-bom:3.0.2"))
}
}

sourceSets {
commonTest {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
implementation("org.jetbrains.kotlin:kotlin-test-common")
}
}
}

sourceSets {
val backendMain by getting {
dependencies {
implementation("io.ktor:ktor-server-netty")
implementation("io.ktor:ktor-server-html-builder")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("ch.qos.logback:logback-classic:1.5.12")
}
}
val backendTest by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test")
implementation("org.jetbrains.kotlin:kotlin-test-junit")
}
}
val frontendMain by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
implementation("org.jetbrains.kotlin:kotlin-test-js")
implementation("io.ktor:ktor-client-core")
implementation("io.ktor:ktor-client-js")
// specify ws version explicitly to fix webpack task
implementation(npm("ws", "8.18.0")) // TODO should be removed, after ktor 3.0.3 release (KTOR-7912)
}
}
}
}

repositories {
mavenCentral()
}

val backendJar = tasks.getByName<Jar>("backendJar") {
stokado marked this conversation as resolved.
Show resolved Hide resolved
val frontendBrowserProductionWebpack = tasks.getByName<KotlinWebpack>("frontendBrowserProductionWebpack")
dependsOn(frontendBrowserProductionWebpack)
from(frontendBrowserProductionWebpack.outputDirectory, frontendBrowserProductionWebpack.mainOutputFileName)
}

tasks.register<JavaExec>("run") {
dependsOn(backendJar)
mainClass.set("io.ktor.samples.fullstack.backend.BackendCodeKt")
classpath = files(configurations.getByName("backendRuntimeClasspath"), backendJar)
args = listOf<String>()
}
10 changes: 0 additions & 10 deletions fullstack-mpp/settings.gradle

This file was deleted.

18 changes: 18 additions & 0 deletions fullstack-mpp/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rootProject.name = "ktor-samples"

pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}

fun module(group: String, name: String) {
include(name)
project(":$name").projectDir = file("$group/$name")
}

// ---------------------------

module("samples", "fullstack-mpp")
4 changes: 1 addition & 3 deletions fullstack-mpp/src/backendMain/kotlin/BackendCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ fun Application.main() {
get("/test") {
call.respond("I am a test response")
}
static("/static") {
resources()
}
staticResources(remotePath = "/static", basePackage = null)
}
}

Expand Down
4 changes: 1 addition & 3 deletions fullstack-mpp/src/frontendMain/kotlin/FrontendCode.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.ktor.samples.fullstack.frontend

import io.ktor.client.*
import io.ktor.client.call.body
import io.ktor.client.engine.js.*
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.samples.fullstack.common.*
import kotlinx.browser.document
import kotlinx.browser.window
import kotlinx.browser.*

Check warning

Code scanning / detekt

Wildcard imports should be replaced with imports using fully qualified class names. Wildcard imports can lead to naming conflicts. A library update can introduce naming clashes with your classes which results in compilation errors. Warning

kotlinx.browser.* is a wildcard import. Replace it with fully qualified imports.
import kotlinx.coroutines.*

private val client = HttpClient(Js)
Expand Down
Loading