forked from ktorio/ktor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
86 lines (73 loc) · 2.75 KB
/
build.gradle
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
buildscript {
repositories {
mavenLocal()
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' }
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
fromPreset(presets.jvm, 'backend')
fromPreset(presets.js, 'frontend') {
[tasks.getByName(compilations.main.compileKotlinTaskName), tasks.getByName(compilations.test.compileKotlinTaskName)]*.kotlinOptions {
languageVersion = "1.3"
moduleKind = "umd"
sourceMap = true
metaInfo = true
}
}
}
sourceSets {
backendMain
frontendMain
}
}
repositories {
jcenter()
maven { url "https://kotlin.bintray.com/ktor" }
maven { url "https://kotlin.bintray.com/kotlin/kotlinx" }
}
dependencies {
backendMainImplementation "io.ktor:ktor-server-netty:$ktor_version"
backendMainImplementation "io.ktor:ktor-html-builder:$ktor_version"
backendMainImplementation "ch.qos.logback:logback-classic:$logback_version"
commonMainImplementation "org.jetbrains.kotlin:kotlin-stdlib-common"
commonTestImplementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
commonTestImplementation "org.jetbrains.kotlin:kotlin-test-common"
frontendMainImplementation "org.jetbrains.kotlin:kotlin-stdlib-js"
frontendTestImplementation "org.jetbrains.kotlin:kotlin-test-js"
backendMainImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
backendTestImplementation "org.jetbrains.kotlin:kotlin-test"
backendTestImplementation "org.jetbrains.kotlin:kotlin-test-junit"
}
def webFolder = new File(project.buildDir, "../src/frontendMain/web")
def frontendCompilations = kotlin.targets.frontend.compilations
task populateWebFolder(dependsOn: [frontendMainClasses]) {
doLast {
copy {
from frontendCompilations.main.output
from kotlin.sourceSets.frontendMain.resources.srcDirs
frontendCompilations.test.runtimeDependencyFiles.each {
if (it.exists() && !it.isDirectory()) {
from zipTree(it.absolutePath).matching { include '*.js' }
}
}
into webFolder
}
}
}
frontendJar.dependsOn(populateWebFolder)
task run(type: JavaExec, dependsOn: [backendMainClasses, frontendJar]) {
//main = "io.ktor.samples.fullstack.backend.BackendCodeKt"
main = "io.ktor.server.netty.DevelopmentEngine"
classpath { [
kotlin.targets.backend.compilations.main.output.files,
configurations.backendRuntimeClasspath,
] }
args = []
}