-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
138 lines (118 loc) · 4.5 KB
/
build.gradle.kts
File metadata and controls
138 lines (118 loc) · 4.5 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
val kotlinVersion = "1.4.0"
val serializationVersion = "1.0.0-RC"
val ktorVersion = "1.4.3"
plugins {
kotlin("multiplatform") version "1.4.0"
application //to run JVM part
kotlin("kapt") version "1.4.31"
kotlin("plugin.serialization") version "1.4.0"
id("org.springframework.boot") version "2.4.5"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
mavenCentral()
jcenter()
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
}
kotlin {
jvm {
withJava()
}
js {
browser {
binaries.executable()
}
}
dependencies {
implementation("com.github.mfarsikov:kotlite-core:0.3.1") // library containing annotations and classes used in compile time
implementation("com.google.code.gson:gson:2.8.5")
implementation("org.xerial:sqlite-jdbc:3.34.0")
implementation ("org.springframework.boot:spring-boot-dependencies:2.1.0.RELEASE")
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.github.mfarsikov:kotlite-core:0.3.1") // library containing annotations and classes used in compile time
implementation(kotlin("stdlib-common"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:1.3.2")
}
}
val jvmMain by getting {
dependencies {
jvm().compilations["main"].defaultSourceSet {
dependencies {
configurations["kapt"].dependencies.add(project.dependencies.create("com.github.mfarsikov:kotlite-kapt:0.3.1"))
}
}
implementation("io.ktor:ktor-serialization:$ktorVersion")
implementation("io.ktor:ktor-server-core:$ktorVersion")
implementation("io.ktor:ktor-server-netty:$ktorVersion")
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("io.ktor:ktor-websockets:$ktorVersion")
implementation("org.litote.kmongo:kmongo-coroutine-serialization:4.1.1")
}
}
val jsMain by getting {
dependencies {
implementation("io.ktor:ktor-client-js:$ktorVersion") //include http&websockets
//ktor client js json
implementation("io.ktor:ktor-client-json-js:$ktorVersion")
implementation("io.ktor:ktor-client-serialization-js:$ktorVersion")
implementation("io.ktor:ktor-client-cio:1.3.2")
implementation("org.jetbrains:kotlin-react:16.13.1-pre.110-kotlin-1.4.0")
implementation("org.jetbrains:kotlin-react-dom:16.13.1-pre.110-kotlin-1.4.0")
implementation(npm("react", "16.13.1"))
implementation(npm("react-dom", "16.13.1"))
}
}
}
kapt {
arguments {
arg("kotlite.db.qualifiedName", "universe.db") // default database class name
arg("kotlite.spring", "false") // marks database class as Spring's component
}
}
}
application {
mainClassName = "ServerKt"
}
// include JS artifacts in any JAR we generate
tasks.getByName<Jar>("jvmJar") {
val taskName = if (project.hasProperty("isProduction")) {
"jsBrowserProductionWebpack"
} else {
"jsBrowserDevelopmentWebpack"
}
val webpackTask = tasks.getByName<KotlinWebpack>(taskName)
dependsOn(webpackTask) // make sure JS gets compiled first
from(File(webpackTask.destinationDirectory, webpackTask.outputFileName)) // bring output file along into the JAR
}
tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
distributions {
main {
contents {
from("$buildDir/libs") {
rename("${rootProject.name}-jvm", rootProject.name)
into("lib")
}
}
}
}
// Alias "installDist" as "stage" (for cloud providers)
tasks.create("stage") {
dependsOn(tasks.getByName("installDist"))
}
tasks.getByName<JavaExec>("run") {
classpath(tasks.getByName<Jar>("jvmJar")) // so that the JS artifacts generated by `jvmJar` can be found and served
}