-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
101 lines (81 loc) · 2.34 KB
/
build.gradle
File metadata and controls
101 lines (81 loc) · 2.34 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
plugins {
id 'java'
id 'com.gradleup.shadow' version '9.3.1'
}
group = 'com.hyperhomes'
version = '0.1.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
repositories {
mavenCentral()
}
dependencies {
// Hytale Server API (provided at runtime)
compileOnly files(rootProject.hytaleServerJar)
// HyperPerms soft dependency (for compile-time reference only)
// Actual integration uses reflection to avoid hard dependency
compileOnly project(':HyperPerms')
// JSON handling
implementation 'com.google.code.gson:gson:2.11.0'
// Null safety annotations
compileOnly 'org.jetbrains:annotations:24.1.0'
// Testing
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
// Generate BuildInfo.java with project version
def generatedSrcDir = layout.buildDirectory.dir("generated/sources/buildinfo/java")
sourceSets.main.java.srcDir(generatedSrcDir)
tasks.register('generateBuildInfo') {
def outputDir = generatedSrcDir
def ver = version
inputs.property('version', ver)
outputs.dir(outputDir)
doLast {
def dir = outputDir.get().asFile.toPath().resolve("com/hyperhomes").toFile()
dir.mkdirs()
new File(dir, "BuildInfo.java").text = """\
package com.hyperhomes;
/**
* Auto-generated build information.
*/
public final class BuildInfo {
public static final String VERSION = "${ver}";
public static final String JAVA_VERSION = "${System.getProperty('java.version')}";
public static final long BUILD_TIMESTAMP = ${System.currentTimeMillis()}L;
private BuildInfo() {}
}
"""
}
}
processResources {
filesMatching('manifest.json') {
expand(version: version)
}
}
jar {
archiveClassifier = 'plain'
}
shadowJar {
archiveClassifier.set('')
// Relocate dependencies to avoid conflicts
relocate 'com.google.gson', 'com.hyperhomes.lib.gson'
minimize()
}
test {
useJUnitPlatform()
}
build {
dependsOn shadowJar
}
// Ensure build info is generated and HyperPerms shadowJar is built before compiling
tasks.named('compileJava') {
dependsOn 'generateBuildInfo', ':HyperPerms:shadowJar'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs.addAll(['-Xlint:all', '-Xlint:-processing'])
}