-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
275 lines (251 loc) · 9.42 KB
/
Copy pathbuild.gradle
File metadata and controls
275 lines (251 loc) · 9.42 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
plugins {
id 'java'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4'
id 'maven-publish'
id 'org.jreleaser' version '1.22.0'
id 'signing'
}
import org.gradle.internal.os.OperatingSystem
ext {
if (project.hasProperty('hytale_home')) {
hytaleHome = project.findProperty('hytale_home')
// Traverse up to the Hytale base directory
// latest/ game/ package/ $patchline/install/
// | | | | |
hytaleBase = file(hytaleHome).parentFile.parentFile.parentFile.parentFile.parentFile.absolutePath
}
else {
def os = OperatingSystem.current()
def base = null
if (os.isWindows()) {
base = "${System.getProperty("user.home")}/AppData/Roaming/Hytale"
}
else if (os.isMacOsX()) {
base = "${System.getProperty("user.home")}/Library/Application Support/Hytale"
}
else if (os.isLinux()) {
base = "${System.getProperty("user.home")}/.var/app/com.hypixel.HytaleLauncher/data/Hytale"
if (!file(base).exists()) {
base = "${System.getProperty("user.home")}/.local/share/Hytale"
}
}
if (base != null) {
hytaleBase = base
hytaleHome = "${hytaleBase}/install/$patchline/package/game/latest/Server"
}
}
}
if (project.hasProperty('hytale_home')) {
if (!file(hytaleHome).exists()) {
throw new GradleException("Failed to find Hytale at the specified hytale_home: $hytaleHome")
}
} else if (hytaleHome == null || !file(hytaleHome).exists()) {
// Use HytaleServer.jar from the current directory as a fallback.
hytaleBase = "."
hytaleHome = "${hytaleBase}/server"
println "Warning: Could not locate Hytale installation. Falling back to using ${hytaleHome}/HytaleServer.jar from the current directory."
println "If you have a copy of Hytale install it via the official way or consider specifying the 'hytale_home' project property to point to your custom installation."
println "Example: gradle build -Phytale_home=\"/path/to/Hytale/install/<patchline>/package/game/latest/Server\""
}
group = maven_group
java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
withSourcesJar()
withJavadocJar()
}
// Quiet warnings about missing Javadocs.
javadoc {
options.addStringOption('Xdoclint:-missing', '-quiet')
}
repositories {
mavenCentral()
exclusiveContent {
forRepository {
maven {
url "https://cursemaven.com"
}
}
filter {
includeGroup "curse.maven"
}
}
}
dependencies {
// Adds the Hytale server as a build dependency, allowing you to reference and
// compile against their code. This requires you to have Hytale installed using
// the official launcher for now or using the script from `CONTRIBUTING.md`.
// `implementation` allows the HytaleServer.jar to be executed by IDEA run configuration
// and VSCode launch configuration. The `jar {}` section below excludes it from being bundled
// into the plugin jar.
implementation files("$hytaleHome/HytaleServer.jar")
implementation 'com.google.code.gson:gson:2.13.2'
implementation 'com.google.dagger:dagger:2.59.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.59.1'
implementation 'org.xerial:sqlite-jdbc:3.51.1.0'
// HyUI library for building Hytale-compatible user interfaces.
// Currently pointing to: HyUI-0.8.0-all.jar
implementation "curse.maven:hyui-1431415:7588625"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:6.1.0-M1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:6.1.0-M1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:6.1.0-M1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:6.1.0-M1'
testRuntimeOnly 'org.mockito:mockito-core:5.21.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.21.0'
}
jar {
enabled = true
archiveClassifier = ""
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.runtimeClasspath.collect {
// Exclude the HytaleServer.jar from being included in the plugin jar.
(it.isDirectory() || it.name != "HytaleServer.jar") ? (it.isDirectory() ? it : zipTree(it)) : []
}
}
}
test {
useJUnitPlatform()
}
publishing {
publications {
maven(MavenPublication) {
groupId = group
artifactId = artifact_id
from components.java
pom {
name = "Sloud Hytale Portals"
description = "Portal system for Hytale. Teleport to other worlds or points of interest."
url = "https://github.com/${System.getenv("GITHUB_REPOSITORY")}"
inceptionYear = "2026"
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
id = "joeyaurel"
name = "Joey Aurel"
}
}
scm {
connection = "scm:git:git://github.com/${System.getenv("GITHUB_REPOSITORY")}.git"
developerConnection = "scm:git:ssh://github.com/${System.getenv("GITHUB_REPOSITORY")}.git"
url = "https://github.com/${System.getenv("GITHUB_REPOSITORY")}"
}
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/${System.getenv("GITHUB_REPOSITORY")}"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "LocalStaging"
url = layout.buildDirectory.dir('staging-deploy')
}
}
}
jreleaser {
signing {
pgp {
active = 'ALWAYS'
armored = true
}
}
release {
github {
skipRelease = true
}
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
}
}
}
// Create the working directory to run the server if it does not already exist.
def serverRunDir = file("$projectDir/run")
if (!serverRunDir.exists()) {
serverRunDir.mkdirs()
}
// Updates the manifest.json file with the latest properties defined in the
// build.properties file. Currently we update the version and if packs are
// included with the plugin.
tasks.register('updatePluginManifest') {
def manifestFile = file('src/main/resources/manifest.json')
doLast {
if (!manifestFile.exists()) {
throw new GradleException("Could not find manifest.json at ${manifestFile.path}!")
}
def manifestJson = new groovy.json.JsonSlurper().parseText(manifestFile.text)
manifestJson.Version = version
manifestJson.IncludesAssetPack = includes_pack.toBoolean()
manifestFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(manifestJson))
}
}
// Makes sure the plugin manifest is up to date.
tasks.named('processResources') {
dependsOn 'updatePluginManifest'
}
def createServerRunArguments(String srcDir) {
def programParameters = '--allow-op --disable-sentry --assets="' + "${hytaleBase}/install/$patchline/package/game/latest/Assets.zip" + '"'
def modPaths = []
if (includes_pack.toBoolean()) {
modPaths << srcDir
}
if (load_user_mods.toBoolean()) {
modPaths << "${hytaleBase}/UserData/Mods"
}
if (!modPaths.isEmpty()) {
programParameters += ' --mods="' + modPaths.join(',') + '"'
}
return programParameters
}
// Creates a run configuration in IDEA that will run the Hytale server with
// your plugin and the default assets.
idea.project.settings.runConfigurations {
'HytaleServer'(org.jetbrains.gradle.ext.Application) {
mainClass = 'com.hypixel.hytale.Main'
moduleName = project.idea.module.name + '.main'
programParameters = createServerRunArguments(sourceSets.main.java.srcDirs.first().parentFile.absolutePath)
workingDirectory = serverRunDir.absolutePath
}
}
// Creates a launch.json file for VSCode with the same configuration
tasks.register('generateVSCodeLaunch') {
def vscodeDir = file("$projectDir/.vscode")
def launchFile = file("$vscodeDir/launch.json")
doLast {
if (!vscodeDir.exists()) {
vscodeDir.mkdirs()
}
def programParams = createServerRunArguments("\${workspaceFolder}")
def launchConfig = [
version: "0.2.0",
configurations: [
[
type: "java",
name: "HytaleServer",
request: "launch",
mainClass: "com.hypixel.hytale.Main",
args: programParams,
cwd: "\${workspaceFolder}/run"
]
]
]
launchFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(launchConfig))
}
}