generated from utopia-rise/godot-kotlin-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
115 lines (96 loc) · 3.84 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
import org.gradle.internal.os.OperatingSystem
import java.net.URL
import java.util.zip.ZipInputStream
plugins {
kotlin("jvm") version "1.9.23"
id("com.utopia-rise.godot-kotlin-jvm") version "0.9.0-4.2.2"
id("org.jetbrains.compose") version "1.6.11"
}
repositories {
mavenLocal()
mavenCentral()
google()
maven("https://repo.gradle.org/gradle/libs-releases/")
}
dependencies {
implementation(compose.desktop.currentOs)
implementation("org.jetbrains.skiko:skiko-awt-runtime-linux-x64:0.8.12")
implementation("io.github.ismai117:kottie:2.0.0")
implementation("org.gradle:gradle-tooling-api:8.10.2")
implementation("org.slf4j:slf4j-simple:1.7.32") // Simple SLF4J binding for console logging
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
}
val godotVersion = "4.2.2"
val godotKotlinVersion = "0.9.0"
val godotOs = when {
OperatingSystem.current().isWindows -> "win64"
OperatingSystem.current().isMacOsX -> "macos"
else -> "x11" // Linux or BSD
}
val godotExecutableName = when {
OperatingSystem.current().isWindows -> "godot.windows.editor.x86_64.exe"
OperatingSystem.current().isMacOsX -> "godot.macos.editor.x86_64"
else -> "godot.linuxbsd.editor.x86_64"
}
val godotFolderName = "godot-kotlin-jvm_editor_x11_$godotKotlinVersion-$godotVersion"
val godotPath = "${System.getProperty("user.home")}/.godot-kotlin/$godotFolderName"
val godotExecutablePath = "$godotPath/$godotExecutableName"
tasks.register("downloadGodot") {
doLast {
val godotFile = File(godotExecutablePath)
if (!godotFile.exists()) {
val url = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/$godotKotlinVersion-$godotVersion/godot-kotlin-jvm_editor_${godotOs}_$godotKotlinVersion-$godotVersion.zip"
println("Downloading Godot with Kotlin bindings...")
URL(url).openStream().use { input ->
ZipInputStream(input).use { zip ->
var entry = zip.nextEntry
while (entry != null) {
val filePath = File(godotPath, entry.name)
if (!entry.isDirectory) {
filePath.parentFile.mkdirs()
filePath.outputStream().use { output ->
zip.copyTo(output)
}
}
entry = zip.nextEntry
}
}
}
println("Godot with Kotlin bindings has been downloaded and extracted.")
if (!OperatingSystem.current().isWindows)
godotFile.setExecutable(true)
else
println("Godot with Kotlin bindings is already installed.")
}
}
}
tasks.register("launchGodot") {
dependsOn("downloadGodot")
doLast {
val godotFile = file(godotExecutablePath)
if (!godotFile.exists()) {
throw GradleException("Godot executable not found. Please run the downloadGodot task first.")
}
val scene = project.findProperty("scene") as String?
val command = mutableListOf(godotExecutablePath, "--path", projectDir.absolutePath)
if (scene != null) {
println("Launching Godot with scene: $scene")
command.add(scene)
} else {
println("Launching Godot without a specific scene")
}
exec {
commandLine(command)
workingDir = projectDir
}
}
}
godot {
registrationFileBaseDir.set(projectDir.resolve("scripts"))
isRegistrationFileHierarchyEnabled.set(true)
// To enable Android Export.
//isAndroidExportEnabled.set(true)
// To enable iOS export and Graal Native Image export.
//isGraalNativeImageExportEnabled.set(true)
}