-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
227 lines (190 loc) · 8.33 KB
/
build.gradle
File metadata and controls
227 lines (190 loc) · 8.33 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
// ================================================================
// 🎮 PermGuard - Minecraft Plugin
// ================================================================
// 📖 Repository: https://github.com/alex2276564/PermGuard
// 🔧 Build tool: Gradle
// ☕ Java version: 17
// 🎯 Target: Paper/Folia 1.16.5+
// ================================================================
// ================================================================
// 🔌 PLUGINS
// ================================================================
// Core build plugins and tooling
// ================================================================
plugins {
id 'java'
id 'com.gradleup.shadow' version '9.4.1' // Shadow JAR (shading dependencies)
id 'xyz.jpenilla.run-paper' version '3.0.2' // Paper test server runner
}
// ================================================================
// 📦 PROJECT INFORMATION
// ================================================================
group = 'uz.alex2276564'
version = '1.0.5'
// ================================================================
// ☕ JAVA CONFIGURATION
// ================================================================
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
// Use toolchain if current Java version is older than target
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
// ================================================================
// 📚 REPOSITORIES
// ================================================================
// Maven repositories for dependency resolution
// ================================================================
repositories {
// ----------------------------------------------------------------
// 🌍 Public repositories
// ----------------------------------------------------------------
mavenCentral()
// ----------------------------------------------------------------
// 📦 Minecraft/Paper repositories
// ----------------------------------------------------------------
maven {
name = 'papermc-repo'
url = 'https://repo.papermc.io/repository/maven-public/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
// ----------------------------------------------------------------
// 🔌 Plugin repositories
// ----------------------------------------------------------------
maven {
name = 'okaeri'
url = 'https://repo.okaeri.cloud/releases'
}
maven {
name = 'tcoded-releases'
url = 'https://repo.tcoded.com/releases'
}
}
// ================================================================
// 📦 DEPENDENCIES
// ================================================================
// Project dependencies organized by category
// ================================================================
dependencies {
// ----------------------------------------------------------------
// 🎮 Minecraft API (compileOnly - provided by server)
// ----------------------------------------------------------------
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
// ----------------------------------------------------------------
// 🔌 Plugin APIs (compileOnly - optional soft dependencies)
// ----------------------------------------------------------------
compileOnly 'net.kyori:adventure-text-minimessage:4.26.1'
// ----------------------------------------------------------------
// 🛠️ Development tools (compileOnly + annotationProcessor)
// ----------------------------------------------------------------
compileOnly 'org.projectlombok:lombok:1.18.44'
annotationProcessor 'org.projectlombok:lombok:1.18.44'
testCompileOnly 'org.projectlombok:lombok:1.18.44'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.44'
// ----------------------------------------------------------------
// 📚 Libraries (implementation - will be shaded into final JAR)
// ----------------------------------------------------------------
// Configuration library
implementation 'eu.okaeri:okaeri-configs-yaml-snakeyaml:5.0.13'
// JSON serialization (required for legacy 1.16.x compatibility)
implementation 'com.google.code.gson:gson:2.13.2'
// Folia compatibility layer
implementation 'com.tcoded:FoliaLib:0.5.1'
}
// ================================================================
// 🔒 DEPENDENCY LOCKING
// ================================================================
// Ensures reproducible builds and better security scanning
//
// 📝 How to use:
// • When adding/updating dependencies, run:
// ./gradlew dependencies --write-locks
// • Commit both build.gradle and gradle.lockfile
// • Renovate will automatically update lockfile in PRs
//
// 🔐 Benefits:
// • Reproducible builds across environments
// • Security scanners (OSV, Trivy) see ALL dependencies
// • Protection against dependency confusion attacks
// ================================================================
dependencyLocking {
lockAllConfigurations()
}
// ================================================================
// 📦 SHADOW JAR (SHADING)
// ================================================================
// ⚠️ IMPORTANT: Shading is REQUIRED for legacy compatibility!
//
// Why shading is necessary:
// • Old server versions (1.16.x and below) don't provide modern libraries
// • Libraries like Gson may be outdated or missing on legacy servers
// • Shading ensures all dependencies are bundled and isolated
// • Prevents conflicts with other plugins using different versions
//
// Relocation strategy:
// • All shaded libraries moved to uz.alex2276564.permguard.libs.*
// • This prevents classpath conflicts with other plugins
// ================================================================
shadowJar {
// Don't append '-all' suffix to JAR filename
archiveClassifier.set('')
// Merge service files (required for some libraries)
mergeServiceFiles()
// ----------------------------------------------------------------
// 📦 Library relocations (prevent conflicts)
// ----------------------------------------------------------------
relocate 'eu.okaeri.configs', 'uz.alex2276564.permguard.libs.okaeri.configs'
relocate 'org.yaml.snakeyaml', 'uz.alex2276564.permguard.libs.snakeyaml'
relocate 'com.google.gson', 'uz.alex2276564.permguard.libs.gson'
relocate 'com.tcoded.folialib', 'uz.alex2276564.permguard.libs.folialib'
}
// ================================================================
// 🏗️ BUILD CONFIGURATION
// ================================================================
// Always build shadowJar instead of regular JAR
build {
dependsOn shadowJar
}
// ================================================================
// ⚙️ TASKS
// ================================================================
// ----------------------------------------------------------------
// 🎮 Development server (run-paper plugin)
// ----------------------------------------------------------------
tasks {
runServer {
// Minecraft version for local testing
// Plugin JAR (shadowJar) will be automatically loaded
minecraftVersion('1.16.5')
}
}
// ----------------------------------------------------------------
// ☕ Java compilation
// ----------------------------------------------------------------
tasks.withType(JavaCompile).configureEach {
// Use UTF-8 encoding for source files
options.encoding = 'UTF-8'
// Use --release flag if Java 10+ (better compatibility)
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
// ----------------------------------------------------------------
// 📄 Resource processing (plugin.yml, config.yml, etc.)
// ----------------------------------------------------------------
processResources {
// Expand ${version} placeholder in plugin.yml
def props = [version: version]
inputs.properties props
filteringCharset = 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}