-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
106 lines (89 loc) · 3.05 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
@file:Suppress("UNUSED_VARIABLE")
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDistributionDsl
plugins {
kotlin("multiplatform") version "1.8.20"
}
repositories {
mavenLocal()
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
kotlin {
// kotlin multiplatform (jvm + js) setup:
jvm {
jvmToolchain(11)
}
js(IR) {
binaries.executable()
browser {
@OptIn(ExperimentalDistributionDsl::class)
distribution {
directory = File("${rootDir}/dist/js")
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
// add additional kotlin multi-platform dependencies here...
// kool dependencies - choose your version:
val koolVersion = "0.11.0" // stable version
//val koolVersion = "0.12.0-SNAPSHOT" // newer but minor breaking changes might occur from time to time
implementation("de.fabmax.kool:kool-core:$koolVersion")
implementation("de.fabmax.kool:kool-physics:$koolVersion")
}
}
val jvmMain by getting {
dependencies {
// add additional jvm-specific dependencies here...
// add dependencies for required lwjgl runtime libs
val platform = "natives-windows" // and / or "natives-linux", "natives-macos"
val lwjglVersion = "3.3.2"
listOf("glfw", "opengl", "jemalloc", "nfd", "stb", "vma", "shaderc").forEach { lib ->
runtimeOnly("org.lwjgl:lwjgl-$lib:$lwjglVersion:$platform")
}
runtimeOnly("org.lwjgl:lwjgl:$lwjglVersion:$platform")
}
}
val jsMain by getting {
dependencies {
// add additional js-specific dependencies here...
}
}
}
}
task("runnableJar", Jar::class) {
dependsOn("jvmJar")
group = "app"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveAppendix.set("runnable")
manifest {
attributes["Main-Class"] = "LauncherKt"
}
val jvmConfig = configurations.getByName("jvmRuntimeClasspath").copyRecursive()
from(
jvmConfig.fileCollection { true }.files.map { if (it.isDirectory) it else zipTree(it) },
files("$buildDir/classes/kotlin/jvm/main")
)
doLast {
copy {
from("$buildDir/libs/${archiveBaseName.get()}-runnable.jar")
into("${rootDir}/dist/jvm")
}
}
}
task("launch", JavaExec::class) {
group = "app"
dependsOn("jvmMainClasses")
val jvmConfig = configurations.getByName("jvmRuntimeClasspath").copyRecursive()
classpath = jvmConfig.fileCollection { true } + files("$buildDir/classes/kotlin/jvm/main")
mainClass.set("LauncherKt")
}
val build by tasks.getting(Task::class) {
dependsOn("runnableJar")
}
val clean by tasks.getting(Task::class) {
doLast {
delete("${rootDir}/dist")
}
}