-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
122 lines (102 loc) · 3.74 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
122 lines (102 loc) · 3.74 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
import java.io.FileNotFoundException
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.google.code.gson:gson:2.14.0")
}
}
plugins {
id("java")
}
val modVersion = providers.gradleProperty("mod.version").get()
val hytaleVersion = providers.gradleProperty("hytale.version").get()
val hytalePatchline = providers.gradleProperty("hytale.patchline").getOrElse("release")
group = "me.nullicorn"
version = modVersion
repositories {
maven {
name = "hytale-$hytalePatchline"
url = uri("https://maven.hytale.com/$hytalePatchline/")
}
}
dependencies {
implementation("com.hypixel.hytale:Server:$hytaleVersion")
}
val pluginProcessResourcesTask = tasks.register<Copy>("pluginProcessResources") {
description = "Copy non-asset resources for the plugin"
group = "hytale"
copy {
from("src/main/resources/manifest.json")
into("build/resources/main/")
filter {
it.replace("\"IncludesAssetPack\": true,", "")
}
}
}
val pluginJarTask = tasks.register<Jar>("pluginJar") {
description = "Packages the plugin without any assets"
group = "hytale"
dependsOn("classes", "pluginProcessResources")
from("build/classes/java/main/", "build/resources/main/manifest.json")
archiveClassifier = "bin"
}
// Turn off 'processResources' if 'pluginProcessResources' is executing.
gradle.taskGraph.whenReady {
if (this.hasTask(pluginProcessResourcesTask.get())) {
tasks.processResources.get().enabled = false
}
}
tasks.jar {
// Exclude EditorConfig (only used during development).
exclude(".editorconfig")
// Exclude files generated by the generateAssetSchema task (only used during development).
exclude("Schema/", ".vscode/")
// Include NOTICE.md and LICENSE.md.
// Also remove any occurrences of "src/main/resources/" from paths within them. That path structure is not present
// in the jar.
from(files("NOTICE.md", "LICENSE.md")) {
filter { content ->
content
.replace("src/main/resources/", "")
.replace("src/main/java/", "")
}
}
}
fun runServer(task: JavaExec, vararg extraArgs: String) {
val hytaleServerArtifact =
project.configurations.compileClasspath.get().resolvedConfiguration.resolvedArtifacts.find { it.moduleVersion.id.group == "com.hypixel.hytale" && it.moduleVersion.id.name == "Server" }
if (hytaleServerArtifact == null) {
throw FileNotFoundException("failed to locate Hytale server dependency and its jar file")
}
val hytaleAssetsZip = layout.projectDirectory.file("run/Assets.zip").asFile
if (!hytaleAssetsZip.isFile) {
throw FileNotFoundException("please copy the Assets.zip file for version ${hytaleServerArtifact.moduleVersion.id.version} into the `run` folder")
}
task.workingDir = layout.projectDirectory.dir("run/").asFile
task.classpath = files(hytaleServerArtifact.file)
task.mainClass = "com.hypixel.hytale.Main"
task.args = listOf(
"--assets", hytaleAssetsZip.path,
// Load our mod jar.
"--mods", layout.buildDirectory.get().dir("libs/").asFile.path,
// Load our mod asset pack.
"--mods", layout.projectDirectory.dir("src/main/").asFile.path,
) + extraArgs
}
tasks.register<JavaExec>("runServer") {
dependsOn("pluginJar")
group = "hytale"
// Allow Hytale console commands to be input through this Gradle task's stdin.
standardInput = System.`in`
runServer(task = this)
}
tasks.register<JavaExec>("generateAssetSchema") {
dependsOn("pluginJar")
group = "hytale"
runServer(
this,
"--generate-asset-schema", layout.projectDirectory.dir("src/main/resources/").asFile.path
)
}