-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
151 lines (140 loc) · 5.34 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
import com.littlekt.gradle.texturepacker.littleKt
import com.littlekt.gradle.texturepacker.packing
import com.littlekt.gradle.texturepacker.texturePacker
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
buildscript {
val littleKtVersion: String by project
repositories {
mavenLocal()
google()
mavenCentral()
maven(url ="https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
classpath("com.littlekt.gradle:texturepacker:$littleKtVersion")
}
}
plugins {
kotlin("multiplatform") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
id("com.littlekt.gradle.texturepacker") version "0.10.0.7be3cb0-SNAPSHOT"
}
group = "com.littlekt.samples"
version = "1.0"
repositories {
mavenLocal()
google()
mavenCentral()
maven(url ="https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
}
littleKt {
texturePacker {
inputDir = "art/export_tiles/"
outputDir = "src/commonMain/resources/"
outputName = "tiles.atlas"
packing {
extrude = 2
}
}
}
kotlin {
tasks.withType<JavaExec> { jvmArgs("--enable-preview", "--enable-native-access=ALL-UNNAMED") }
jvm {
compilations.all { kotlinOptions.jvmTarget = "21" }
compilations {
val main by getting
val mainClassName = (findProperty("jvm.mainClass") as? String)?.plus("Kt")
if (mainClassName == null) {
project.logger.log(
LogLevel.ERROR,
"Property 'jvm.mainClass' has either changed or has not been set. Check 'gradle.properties' and ensure it is properly set!"
)
}
tasks {
register<Copy>("copyResources") {
group = "package"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(named("jvmProcessResources"))
from(main.output.resourcesDir)
destinationDir = File("${layout.buildDirectory.asFile.get()}/publish")
}
register<Jar>("packageFatJar") {
group = "package"
archiveClassifier.set("all")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(named("jvmJar"))
dependsOn(named("copyResources"))
manifest { attributes["Main-Class"] = mainClassName }
destinationDirectory.set(File("${layout.buildDirectory.asFile.get()}/publish/"))
from(
main.runtimeDependencyFiles.map { if (it.isDirectory) it else zipTree(it) },
main.output.classesDirs
)
doLast {
logger.lifecycle(
"[LittleKt] The packaged jar is available at: ${outputs.files.first().parent}"
)
}
}
if (Os.isFamily(Os.FAMILY_MAC)) {
register<JavaExec>("jvmRun") {
jvmArgs("-XstartOnFirstThread")
mainClass.set(mainClassName)
kotlin {
val mainCompile = targets["jvm"].compilations["main"]
dependsOn(mainCompile.compileAllTaskName)
classpath(
{ mainCompile.output.allOutputs.files },
(configurations["jvmRuntimeClasspath"])
)
}
}
}
}
}
}
js {
binaries.executable()
browser {
testTask { useKarma { useChromeHeadless() } }
commonWebpackConfig {
devServer =
(devServer
?: org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
.DevServer())
.copy(
open = mapOf("app" to mapOf("name" to "chrome")),
)
}
}
this.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
compilations.all { kotlinOptions.sourceMap = true }
}
val kotlinCoroutinesVersion: String by project
val littleKtVersion: String by project
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.littlekt:core:$littleKtVersion")
implementation("com.littlekt:scene-graph:$littleKtVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val jsMain by getting {
dependencies {
val kotlinxHtmlVersion = "0.11.0"
implementation("org.jetbrains.kotlinx:kotlinx-html-js:$kotlinxHtmlVersion")
}
}
val jsTest by getting
}
}