-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
157 lines (137 loc) · 5 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.*
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
distribution
application
}
group = "me.az"
version = "0.6-SNAPSHOT"
repositories {
mavenCentral()
mavenLocal()
}
val koolVersion: String by project
kotlin {
// android()
js(IR) {
browser {
binaries.executable()
@Suppress("EXPERIMENTAL_API_USAGE")
distribution {
directory = File("${rootDir}/dist/")
name = "app"
}
commonWebpackConfig {
// small js code
//mode = KotlinWebpackConfig.Mode.PRODUCTION
// readable js code but ~twice the file size
mode = if(project.hasProperty("prod")) Mode.PRODUCTION else Mode.DEVELOPMENT
cssSupport.enabled = true
//outputPath = File(buildDir, "/processedResources/js/main/")
}
}
}
jvm {
withJava()
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xbackend-threads=0"
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("de.fabmax.kool:kool-core:${koolVersion}")
// implementation(":kool-core")
implementation(kotlin("stdlib-common"))
implementation(DepsCommon.kotlinCoroutines)
implementation(DepsCommon.kotlinSerialization)
implementation(DepsCommon.kotlinSerializationJson)
implementation("com.russhwolf:multiplatform-settings-no-arg:0.9")
implementation("org.mifek.wfc:WFC-Kotlin:1.2.1")
}
}
val jsMain by getting {
dependencies {
//implementation(npm("pako", "2.0.4"))
implementation("de.fabmax.kool:kool-core-js:${koolVersion}")
}
}
val jvmMain by getting {
dependencies {
implementation(DepsJvm.lwjgl())
implementation(DepsJvm.lwjgl("stb"))
runtimeOnly(DepsJvm.lwjglNatives("stb"))
runtimeOnly(DepsJvm.lwjglNatives())
runtimeOnly(DepsJvm.lwjglNatives("glfw"))
runtimeOnly(DepsJvm.lwjglNatives("jemalloc"))
runtimeOnly(DepsJvm.lwjglNatives("opengl"))
runtimeOnly(DepsJvm.lwjglNatives("vma"))
runtimeOnly(DepsJvm.lwjglNatives("shaderc"))
runtimeOnly(DepsJvm.lwjglNatives("nfd"))
implementation("de.fabmax.kool:kool-core-jvm:${koolVersion}")
// bundle
implementation(DepsJvm.lwjglNatives(platform = org.gradle.internal.os.OperatingSystem.WINDOWS))
implementation(DepsJvm.lwjglNatives("glfw", org.gradle.internal.os.OperatingSystem.WINDOWS))
implementation(DepsJvm.lwjglNatives("jemalloc", org.gradle.internal.os.OperatingSystem.WINDOWS))
implementation(DepsJvm.lwjglNatives("opengl", org.gradle.internal.os.OperatingSystem.WINDOWS))
implementation(DepsJvm.lwjglNatives("vma", org.gradle.internal.os.OperatingSystem.WINDOWS))
implementation(DepsJvm.lwjglNatives("shaderc", org.gradle.internal.os.OperatingSystem.WINDOWS))
implementation(DepsJvm.lwjglNatives("nfd", org.gradle.internal.os.OperatingSystem.WINDOWS))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
}
}
application {
mainClass.set("MainKt")
}
tasks["clean"].doLast {
delete("${rootDir}/dist/")
delete(rootProject.buildDir)
}
tasks.register<VersionNameUpdate>("updateVersion") {
versionName = "$version"
filesToUpdate = listOf(
kotlin.sourceSets.findByName("commonMain")?.kotlin
?.sourceDirectories
?.map { File(it, "me/az/Version.kt") }
?.find { it.exists() }?.absolutePath ?: ""
)
}
tasks["compileKotlinJs"].dependsOn("updateVersion")
tasks["compileKotlinJvm"].dependsOn("updateVersion")
distributions {
main {
distributionBaseName.set("ttld")
contents {
into("") {
val jvmJar by tasks.getting
from(jvmJar)
}
into("lib/") {
val main by kotlin.jvm().compilations.getting
from(main.runtimeDependencyFiles)
}
into("assets/") {
from("src/commonMain/resources/")
}
}
}
}
gradle.taskGraph.whenReady {
allTasks
.filter { it.hasProperty("duplicatesStrategy") } // Because it's some weird decorated wrapper that I can't cast.
.forEach {
println(it)
it.setProperty("duplicatesStrategy", "EXCLUDE")
}
}