forked from ProjectSWGCore/Holocore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
203 lines (169 loc) · 7.54 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
/***********************************************************************************
* Copyright (c) 2023 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/
plugins {
application
idea
java
kotlin("jvm") version "2.1.0"
id("org.beryx.jlink") version "3.1.1"
}
val javaVersion = JavaVersion.current()
val kotlinTargetJdk = JvmTarget.fromTarget(javaVersion.majorVersion)
val junit5Version = "5.11.3"
val holocoreLogLevel: String? by project
subprojects {
ext {
set("junit5Version", junit5Version)
}
}
repositories {
maven("https://dev.joshlarson.me/maven2")
mavenCentral()
}
application {
mainClass.set("com.projectswg.holocore.ProjectSWG")
mainModule.set("holocore")
}
sourceSets {
main {
java {
output.setResourcesDir(destinationDirectory.get())
}
}
create("utility")
}
tasks.named("processResources").configure { dependsOn("compileJava") }
val utilityImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}
dependencies {
implementation(project(":pswgcommon"))
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation(group="org.jetbrains.kotlinx", name="kotlinx-coroutines-core", version="1.9.0")
implementation(group="org.mongodb", name="mongodb-driver-sync", version="5.2.1")
implementation(group="me.joshlarson", name="fast-json", version="3.0.1")
implementation(group="me.joshlarson", name="jlcommon-network", version="1.1.0")
implementation(group="me.joshlarson", name="jlcommon-argparse", version="0.9.6")
implementation(group="me.joshlarson", name="websocket", version="0.9.4")
val slf4jVersion = "1.7.36"
runtimeOnly(group="org.slf4j", name="slf4j-jdk14", version= slf4jVersion)
utilityImplementation(project(":"))
utilityImplementation(project(":pswgcommon"))
testImplementation(group="org.junit.jupiter", name="junit-jupiter-api", version=junit5Version)
testRuntimeOnly(group="org.junit.jupiter", name="junit-jupiter-engine", version=junit5Version)
testRuntimeOnly(group="org.junit.platform", name="junit-platform-launcher", version="1.11.3")
testImplementation(group="org.junit.jupiter", name="junit-jupiter-params", version=junit5Version)
testImplementation(group="org.testcontainers", name="mongodb", version="1.20.4")
testImplementation("com.tngtech.archunit:archunit-junit5:1.3.0")
}
idea {
module {
inheritOutputDirs = true
excludeDirs.add(project.file("log"))
excludeDirs.add(project.file("mongo_data"))
excludeDirs.add(project.file("odb"))
}
}
jlink {
// addOptions("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")
addOptions("--ignore-signing-information")
forceMerge("kotlin-stdlib")
imageDir.set(layout.buildDirectory.dir("holocore"))
imageZip.set(layout.buildDirectory.file("holocore.zip"))
launcher {
name = "holocore"
jvmArgs = listOf()
unixScriptTemplate = file("src/main/resources/jlink-unix-launch-template.txt")
}
}
tasks.withType<Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).configureEach {
compilerOptions {
jvmTarget.set(kotlinTargetJdk)
}
destinationDirectory.set(File(destinationDirectory.get().asFile.path.replace("kotlin", "java")))
}
tasks.create<JavaExec>("runDevelopment") {
dependsOn(tasks.getByName("test"))
enableAssertions = true
classpath = sourceSets.main.get().runtimeClasspath
mainClass.set("com.projectswg.holocore.ProjectSWG")
if (holocoreLogLevel != null)
args = listOf("--log-level", holocoreLogLevel!!)
}
tasks.create<JavaExec>("runProduction") {
classpath = sourceSets.main.get().runtimeClasspath
mainClass.set("com.projectswg.holocore.ProjectSWG")
if (holocoreLogLevel != null)
args = listOf("--log-level", holocoreLogLevel!!)
}
tasks.replace("run", JavaExec::class).apply {
dependsOn(tasks.getByName("runDevelopment"))
}
tasks.create<JavaExec>("runClientdataConversion") {
enableAssertions = true
classpath = sourceSets["utility"].runtimeClasspath
mainClass.set("com.projectswg.utility.ClientdataConvertAll")
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
events = setOf(TestLogEvent.FAILED, TestLogEvent.SKIPPED)
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.named("classes") {
dependsOn("createRunScript")
}
tasks.register("createRunScript") {
dependsOn("compileJava", "compileKotlin", "processResources")
doLast {
// Use the Java executable that Gradle is using
val javaHome = System.getProperty("java.home")
val javaExecutable = "$javaHome/bin/java"
// Collect runtime classpath elements into a single string with path separator
val runtimeClasspath = configurations["runtimeClasspath"].files.joinToString(File.pathSeparator) {
it.absolutePath
}
// Get the output directory for the main/java source set
val mainJavaOutputDir = project.sourceSets["main"].java.destinationDirectory.get().asFile.absolutePath
// Assemble the module-path to include both the runtime classpath and the main/java output directory
val modulePath = "$runtimeClasspath${File.pathSeparator}$mainJavaOutputDir"
// Assemble the command
val command = "clear; JAVA_HOME=$javaHome ./gradlew classes && $javaExecutable -ea -p $modulePath -m holocore/com.projectswg.holocore.ProjectSWG --print-colors"
// File to write the run command
val outputFile = file("${layout.buildDirectory.asFile.get().absolutePath}/run")
outputFile.writeText(command)
outputFile.setExecutable(true)
}
}