-
-
Notifications
You must be signed in to change notification settings - Fork 202
/
build.gradle.kts
152 lines (127 loc) · 4.09 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
import com.github.jengelman.gradle.plugins.shadow.ShadowApplicationPlugin.SHADOW_INSTALL_TASK_NAME
import com.github.jengelman.gradle.plugins.shadow.ShadowApplicationPlugin.SHADOW_SCRIPTS_TASK_NAME
import org.jetbrains.kotlin.incremental.deleteRecursivelyOrThrow
plugins {
kotlin("jvm")
application
id("com.github.johnrengelman.shadow")
}
group = "com.charlatano"
version = "1.3.0"
dependencies {
val slf4jVersion = "2.0.6"
implementation("org.slf4j:slf4j-api:$slf4jVersion")
implementation("org.slf4j:slf4j-nop:$slf4jVersion")
val jnaVersion = "5.13.0"
implementation("net.java.dev.jna:jna:$jnaVersion")
implementation("net.java.dev.jna:jna-platform:$jnaVersion")
val gdxVersion = "1.11.0"
implementation("com.badlogicgames.gdx:gdx:$gdxVersion")
implementation("com.badlogicgames.gdx:gdx-platform:$gdxVersion")
implementation("com.badlogicgames.gdx:gdx-box2d:$gdxVersion")
implementation("com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion")
implementation("com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion")
implementation("it.unimi.dsi:fastutil:8.5.11")
implementation("net.openhft:chronicle-core:2.24ea6")
implementation("org.jire:kna:0.4.2")
implementation(kotlin("script-runtime"))
implementation(kotlin("main-kts"))
implementation(kotlin("scripting-jsr223"))
}
application {
mainClass.set("com.charlatano.Charlatano")
applicationDefaultJvmArgs += arrayOf(
"-Xmx1024m",
"-Xms512m",
"--enable-preview",
"--enable-native-access=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
}
kotlin {
jvmToolchain(8)
}
tasks {
compileKotlin {
compilerOptions {
freeCompilerArgs.add("-Xinline-classes")
freeCompilerArgs.add("-Xjvm-default=all")
freeCompilerArgs.add("-Xextended-compiler-checks")
}
}
compileJava {
options.compilerArgs.add("--enable-preview")
}
configureShadowJar()
}
sourceSets {
main.configure {
kotlin {
srcDir("settings")
}
}
}
fun TaskContainerScope.configureShadowJar() {
shadowJar {
archiveBaseName.set("Charlatano")
archiveClassifier.set("")
//archiveVersion.set("${project.version}")
isZip64 = true
//minimize() // needs to be updated for Java 19 support
}
named<Zip>("distZip").configure {
enabled = false
}
named<Tar>("distTar").configure {
enabled = false
}
named<CreateStartScripts>("startScripts").configure {
enabled = false
}
named<CreateStartScripts>(SHADOW_SCRIPTS_TASK_NAME).configure {
enabled = false
}
named(SHADOW_INSTALL_TASK_NAME).configure {
enabled = false
}
named("shadowDistTar").configure {
enabled = false
}
named("shadowDistZip").configure {
enabled = false
}
}
fun TaskContainerScope.configureCharlatano() {
register("charlatano") {
dependsOn(shadowJar)
doLast {
val version = version
val name = "Charlatano $version"
val buildDir = file("build/")
val dir = buildDir.resolve(name)
if (dir.exists()) dir.deleteRecursivelyOrThrow()
dir.mkdirs()
val jarName = "${name}.jar"
val jar = dir.resolve(jarName)
val allJar = buildDir.resolve("libs/Charlatano-${version}.jar")
allJar.copyTo(jar, true)
dir.writeStartBat(name, jarName)
fun File.copyFromRoot(path: String) = file(path).copyTo(resolve(path), true)
dir.copyFromRoot("LICENSE.txt")
dir.copyFromRoot("README.md")
val dirSettings = dir.resolve("settings")
dirSettings.listFiles()!!.forEach {
dirSettings.copyFromRoot(it.name)
}
}
}
}
fun File.writeStartBat(name: String, jarName: String) =
resolve("Start ${name}.bat")
.writeText(
"""@echo off
cd /d "%~dp0"
title $name
java ${application.applicationDefaultJvmArgs.joinToString(" ")} -jar "$jarName"
pause"""
)