-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
123 lines (108 loc) · 2.78 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
plugins {
kotlin("multiplatform") version "1.4.10"
id("com.github.johnrengelman.shadow") version "6.1.0"
application
}
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
jcenter()
mavenCentral()
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers") }
maven { url = uri("https://dl.bintray.com/kotlin/kotlinx") }
maven { url = uri("https://dl.bintray.com/kotlin/ktor") }
maven("https://dl.bintray.com/kotlin/kotlin-eap")
}
dependencies {
implementation("org.junit.jupiter:junit-jupiter:5.4.2")
implementation(kotlin("stdlib-jdk8"))
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
withJava()
}
js(LEGACY) {
browser {
binaries.executable()
webpackTask {
cssSupport.enabled = true
}
runTask {
cssSupport.enabled = true
}
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
sourceSets.all {
languageSettings.apply {
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
}
}
sourceSets {
val commonMain by getting {
dependencies {
}
}
val jsMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.0")
}
}
val jvmMain by getting {
dependencies {
implementation("io.ktor:ktor-server-netty:1.4.0")
implementation("io.ktor:ktor-websockets:1.4.0")
implementation("io.ktor:ktor-html-builder:1.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2")
implementation("org.slf4j:slf4j-simple:1.6.1")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
}
}
application {
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
mainClassName = "ServerKt"
}
tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack") {
outputFileName = "main.js"
doLast {
File("$projectDir/build/distributions/main.js")
.copyTo(File("$projectDir/src/jvmMain/resources/static/main.js"), overwrite = true)
File("$projectDir/build/distributions/main.js.map")
.copyTo(File("$projectDir/src/jvmMain/resources/static/main.js.map"), overwrite = true)
println("Copied packed JS")
}
}
tasks.getByName<ProcessResources>("processResources") {
dependsOn(tasks.getByName("jsBrowserProductionWebpack"))
}
tasks.getByName<Jar>("jvmJar") {
dependsOn(tasks.getByName("jsBrowserProductionWebpack"))
}
tasks.getByName<JavaExec>("run") {
dependsOn(tasks.getByName<Jar>("jvmJar"))
classpath(tasks.getByName<Jar>("jvmJar"))
}
tasks.shadowJar {
dependsOn(tasks.getByName("jsBrowserProductionWebpack"))
archiveBaseName.set("build")
archiveClassifier.set("")
archiveVersion.set("")
}