Skip to content

Commit b74da45

Browse files
committed
Replace Hytale download task with published artifact
1 parent bb19afc commit b74da45

File tree

3 files changed

+8
-148
lines changed

3 files changed

+8
-148
lines changed

.github/workflows/maven-publish.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ jobs:
2727
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties') }}
2828
restore-keys: |
2929
${{ runner.os }}-gradle-
30-
- name: Cache Hytale Server
31-
uses: actions/cache@v5
32-
with:
33-
path: |
34-
hytale/libs/HytaleServer.jar
35-
hytale/build/download/hytale-downloader-linux-amd64
36-
key: ${{ runner.os }}-hytale-download
37-
restore-keys: |
38-
${{ runner.os }}-hytale-
39-
- name: Download Hytale Server
40-
env:
41-
HYTALE_DOWNLOADER_CREDENTIALS: ${{ secrets.HYTALE_DOWNLOADER_CREDENTIALS }}
42-
run: ./gradlew :hytale:download-server
4330
- name: Publish with Gradle to Repository
4431
env:
4532
REPOSITORY_USER: ${{ secrets.REPOSITORY_USER }}

hytale/build.gradle.kts

Lines changed: 4 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,10 @@
11
val moduleName by extra("dev.faststats.hytale")
22

3-
val libsDir: Directory = layout.projectDirectory.dir("libs")
4-
val hytaleServerJar: RegularFile = libsDir.file("HytaleServer.jar")
5-
val credentialsFile: RegularFile = layout.projectDirectory.file(".hytale-downloader-credentials.json")
6-
val downloadDir: Provider<Directory> = layout.buildDirectory.dir("download")
7-
val hytaleZip: Provider<RegularFile> = downloadDir.map { it.file("hytale.zip") }
3+
repositories {
4+
maven("https://maven.hytale.com/pre-release")
5+
}
86

97
dependencies {
108
api(project(":core"))
11-
compileOnly(files(hytaleServerJar))
12-
}
13-
14-
tasks.register("download-server") {
15-
group = "hytale"
16-
17-
doLast {
18-
if (hytaleServerJar.asFile.exists()) {
19-
println("HytaleServer.jar already exists, skipping download")
20-
return@doLast
21-
}
22-
23-
val downloaderZip: Provider<RegularFile> = downloadDir.map { it.file("hytale-downloader.zip") }
24-
25-
libsDir.asFile.mkdirs()
26-
downloadDir.get().asFile.mkdirs()
27-
28-
val os = org.gradle.internal.os.OperatingSystem.current()
29-
val downloaderExecutable = when {
30-
os.isLinux -> downloadDir.map { it.file("hytale-downloader-linux-amd64") }
31-
os.isWindows -> downloadDir.map { it.file("hytale-downloader-windows-amd64.exe") }
32-
else -> throw GradleException("Unsupported operating system: ${os.name}")
33-
}
34-
35-
if (!downloaderExecutable.get().asFile.exists()) {
36-
if (!downloaderZip.get().asFile.exists()) ant.invokeMethod(
37-
"get", mapOf(
38-
"src" to "https://downloader.hytale.com/hytale-downloader.zip",
39-
"dest" to downloaderZip.get().asFile.absolutePath
40-
)
41-
) else {
42-
println("hytale-downloader.zip already exists, skipping download")
43-
}
44-
45-
copy {
46-
from(zipTree(downloaderZip))
47-
include(downloaderExecutable.get().asFile.name)
48-
into(downloadDir)
49-
}
50-
} else {
51-
println("Hytale downloader binary already exists, skipping download and extraction")
52-
}
53-
54-
if (downloaderZip.get().asFile.delete()) {
55-
println("Deleted hytale-downloader.zip after extracting binaries")
56-
}
57-
58-
downloaderExecutable.get().asFile.setExecutable(true)
59-
60-
if (!hytaleZip.get().asFile.exists()) {
61-
val credentials = System.getenv("HYTALE_DOWNLOADER_CREDENTIALS")
62-
if (!credentials.isNullOrBlank()) {
63-
if (!credentialsFile.asFile.exists()) {
64-
credentialsFile.asFile.writeText(credentials)
65-
println("Hytale downloader credentials written from environment variable to ${credentialsFile.asFile.absolutePath}")
66-
} else {
67-
println("Using existing credentials file at ${credentialsFile.asFile.absolutePath}")
68-
}
69-
}
70-
71-
val processBuilder = ProcessBuilder(
72-
downloaderExecutable.get().asFile.absolutePath,
73-
"-download-path",
74-
"hytale",
75-
"-credentials-path",
76-
credentialsFile.asFile.absolutePath
77-
)
78-
processBuilder.directory(downloadDir.get().asFile)
79-
processBuilder.redirectErrorStream(true)
80-
val process = processBuilder.start()
81-
82-
process.inputStream.bufferedReader().use { reader ->
83-
reader.lines().forEach { line ->
84-
println(line)
85-
}
86-
}
87-
88-
val exitCode = process.waitFor()
89-
if (exitCode != 0) {
90-
throw GradleException("Hytale downloader failed with exit code: $exitCode")
91-
}
92-
} else {
93-
println("hytale.zip already exists, skipping download")
94-
}
95-
96-
if (hytaleZip.get().asFile.exists()) {
97-
val serverDir = downloadDir.map { it.dir("Server") }
98-
copy {
99-
from(zipTree(hytaleZip))
100-
include("Server/HytaleServer.jar")
101-
into(downloadDir)
102-
}
103-
104-
val extractedJar = serverDir.map { it.file("HytaleServer.jar") }
105-
if (extractedJar.get().asFile.exists()) {
106-
extractedJar.get().asFile.copyTo(hytaleServerJar.asFile, overwrite = true)
107-
serverDir.get().asFile.deleteRecursively()
108-
} else {
109-
throw GradleException("HytaleServer.jar was not found in Server/ subdirectory")
110-
}
111-
112-
if (!hytaleServerJar.asFile.exists()) {
113-
throw GradleException("HytaleServer.jar was not found in hytale.zip")
114-
}
115-
116-
hytaleZip.get().asFile.delete()
117-
println("Deleted hytale.zip after extracting HytaleServer.jar")
118-
} else {
119-
throw GradleException(
120-
"hytale.zip not found at ${hytaleZip.get().asFile.absolutePath}. " +
121-
"The downloader may not have completed successfully."
122-
)
123-
}
124-
}
9+
compileOnly("com.hypixel.hytale:Server:2026.01.22-6f8bdbdc4")
12510
}
126-
127-
tasks.register("update-server") {
128-
group = "hytale"
129-
doFirst {
130-
hytaleServerJar.asFile.delete()
131-
hytaleZip.get().asFile.delete()
132-
}
133-
dependsOn(tasks.named("download-server"))
134-
}
135-
136-
tasks.compileJava {
137-
dependsOn(tasks.named("download-server"))
138-
}

hytale/example-plugin/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
val libsDir: Directory = project(":hytale").layout.projectDirectory.dir("libs")
2-
val hytaleServerJar: RegularFile = libsDir.file("HytaleServer.jar")
1+
repositories {
2+
maven("https://maven.hytale.com/pre-release")
3+
}
34

45
dependencies {
5-
compileOnly(files(hytaleServerJar))
6+
compileOnly("com.hypixel.hytale:Server:2026.01.22-6f8bdbdc4")
67
implementation(project(":hytale"))
78
}
89

0 commit comments

Comments
 (0)