-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
113 lines (97 loc) · 3.12 KB
/
Copy pathbuild.gradle
File metadata and controls
113 lines (97 loc) · 3.12 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
plugins {
id 'java'
}
ext {
hytaleHome = System.getenv('HYTALE_HOME') ?: "${System.getProperty('user.home')}/AppData/Roaming/Hytale"
}
def localTemplateJar = file('libs/HytaleServer.jar')
def envConfiguredJarPath = System.getenv('HYTALE_SERVER_JAR')
def envConfiguredJar = envConfiguredJarPath ? file(envConfiguredJarPath) : null
def launcherJar = file("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar")
def workspaceJarCandidates = []
def searchDir = projectDir
6.times {
searchDir = searchDir?.parentFile
if (searchDir != null) {
workspaceJarCandidates << new File(searchDir, 'HytaleServer.jar')
}
}
def hytaleServerJar = ([localTemplateJar, envConfiguredJar, launcherJar] + workspaceJarCandidates).find {
it != null && it.exists()
}
def effectiveHytaleBuild = hytale_build
if (hytaleServerJar != null) {
try {
def jarManifest = new java.util.jar.JarFile(hytaleServerJar).manifest
def detectedVersion = jarManifest?.mainAttributes?.getValue('Implementation-Version')
if (detectedVersion != null && !detectedVersion.isBlank()) {
effectiveHytaleBuild = detectedVersion
}
} catch (Exception ignored) {
// Keep the configured fallback if manifest lookup fails.
}
}
group = maven_group
version = version
java {
toolchain.languageVersion = JavaLanguageVersion.of((java_version as String).toInteger())
withSourcesJar()
withJavadocJar()
}
javadoc {
options.addStringOption('Xdoclint:-missing', '-quiet')
}
repositories {
mavenCentral()
maven {
name = 'hytale-release'
url = uri('https://maven.hytale.com/release')
}
maven {
name = 'hytale-pre-release'
url = uri('https://maven.hytale.com/pre-release')
}
}
dependencies {
if (hytaleServerJar != null) {
implementation files(hytaleServerJar)
} else {
implementation "com.hypixel.hytale:Server:${effectiveHytaleBuild}"
}
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
tasks.test {
useJUnitPlatform()
}
def serverRunDir = file("$projectDir/run")
if (!serverRunDir.exists()) {
serverRunDir.mkdirs()
}
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()
if (manifestJson.containsKey('ServerVersion')) {
manifestJson.ServerVersion = effectiveHytaleBuild
}
manifestFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(manifestJson))
}
}
tasks.named('processResources') {
dependsOn 'updatePluginManifest'
}
tasks.register('printHytaleJar') {
doLast {
println "Using HytaleServer.jar: ${hytaleServerJar != null ? hytaleServerJar.absolutePath : '(maven dependency)'}"
println "Effective server build: ${effectiveHytaleBuild}"
}
}