forked from Jire/Overwatcheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
131 lines (106 loc) · 3.35 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
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 {
id("overwatcheat-kotlin-project")
application
id("com.github.johnrengelman.shadow") version "7.1.2"
}
group = "org.jire.overwatcheat"
version = "5.1.0"
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(19))
}
}
dependencies {
implementation(libs.slf4j.api)
runtimeOnly(libs.slf4j.simple)
implementation(libs.fastutil)
implementation(libs.javacv.platform)
implementation(libs.affinity)
implementation(libs.chronicle.core)
implementation(libs.jna)
implementation(libs.jna.platform)
}
application {
applicationName = "Overwatcheat"
mainClass.set("org.jire.overwatcheat.Main")
applicationDefaultJvmArgs += arrayOf(
"-Xmx4g",
"-Xms1g",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseZGC",
"--enable-native-access=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.base/java.time=ALL-UNNAMED",
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED"
)
}
tasks {
configureShadowJar()
configureOverwatcheat()
}
fun TaskContainerScope.configureShadowJar() {
shadowJar {
archiveBaseName.set("overwatcheat")
archiveClassifier.set("")
archiveVersion.set("")
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.configureOverwatcheat() {
register("overwatcheat") {
dependsOn(shadowJar)
doLast {
val name = "overwatcheat"
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/overwatcheat.jar")
allJar.copyTo(jar, true)
dir.writeStartBat(name, jarName)
fun File.copyFromRoot(path: String) = file(path).copyTo(resolve(path), true)
dir.copyFromRoot("overwatcheat.cfg")
dir.copyFromRoot("LICENSE.txt")
dir.copyFromRoot("README.md")
}
}
}
fun File.writeStartBat(name: String, jarName: String) =
resolve("run.bat")
.writeText(
"""@echo off
cd /d "%~dp0"
title $name
java ${application.applicationDefaultJvmArgs.joinToString(" ")} -jar "$jarName"
pause"""
)