-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
executable file
·247 lines (199 loc) · 7.29 KB
/
build.gradle
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id "fabric-loom" version "1.7.+"
id "maven-publish"
id "java"
id "idea"
id "com.palantir.git-version" version "3.1.0"
id 'checkstyle'
}
checkstyle {
configFile = project.rootProject.file("checkstyle.xml")
toolVersion = '10.18.0'
}
repositories {
mavenCentral()
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://jitpack.io" }
maven { url "https://masa.dy.fi/maven" }
maven { url "https://maven.nucleoid.xyz" }
maven { url "https://projectlombok.org/edge-releases" }
}
/* top-level props */
group = project.maven_group
/* jar file name */
def details = versionDetails()
// must starts with sem-ver to make the fabric loader happy
version = "${project.mod_version}-${details.gitHash}-mc${project.minecraft_version}"
/* fabric env */
loom {
accessWidenerPath = file("src/main/resources/fuji.accesswidener")
mods {
"${project.mod_id}" {
sourceSet sourceSets.main
}
}
// set the runServer() jvm args
runs {
configureEach {
vmArgs("-Xms8G -Xmx8G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:+UseLargePages -XX:+UseTransparentHugePages -Duser.timezone=GMT+08 -Dmixin.debug.export=false".split(" "))
}
}
}
/**
* Each time adds a new library, you should build the software, and go to the production-env to check whether the library works.
*
* It's possible the necessary libraries are not packed into the release package, even you `include` the library ...
*
*/
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings_version}"
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
compileOnly "org.projectlombok:lombok:${project.lombok_version}"
annotationProcessor "org.projectlombok:lombok:${project.lombok_version}"
testCompileOnly "org.projectlombok:lombok:${project.lombok_version}"
testAnnotationProcessor "org.projectlombok:lombok:${project.lombok_version}"
implementation "com.google.code.gson:gson:${project.gson_version}"
include(implementation("com.jayway.jsonpath:json-path:${project.json_path_version}"))
modImplementation("carpet:fabric-carpet:${project.carpet_core_version}")
include(implementation "net.luckperms:api:${project.luckperms_api_version}")
include(modImplementation("eu.pb4:sgui:${project.sgui_version}"))
include(modImplementation("eu.pb4:placeholder-api:${project.placeholder_api_version}"))
include(implementation "org.quartz-scheduler:quartz:${project.quartz_version}")
testImplementation(platform("org.junit:junit-bom:${project.junit_version}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation "io.github.classgraph:classgraph:${project.classgraph_version}"
testImplementation "net.fabricmc:fabric-loader-junit:${project.fabric_loader_version}"
}
/* compile */
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release.set(21)
configure(options) {
// include the 'parameter name' in compiled .class file, for command annotation processor reflection
options.compilerArgs << '-parameters'
// yeah, the code of fuji is more dynamic.
options.compilerArgs << '-Xlint:-unchecked'
}
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
/* build */
processResources {
outputs.upToDateWhen { false }
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
jar {
from("LICENSE") {
rename { "${it}" }
}
}
/* publish */
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {}
}
/* test framework */
test {
useJUnitPlatform()
filter {}
}
/* validate the access widener file */
tasks.compileJava.dependsOn(validateAccessWidener)
/* compile latex */
def processTexDir = file("${layout.buildDirectory.get()}/processTeX")
def outputTexDir = file("${layout.buildDirectory.get()}/outTeX")
def outputTexFile = "fuji.pdf"
def docsDir = file("$projectDir/docs")
def recreateDir(File dir) {
if (dir.exists()) {
println "Delete existing directory: $dir"
dir.deleteDir()
}
println "Mkdir the directory: $dir"
dir.mkdirs()
}
tasks.register('processLatex', Copy) {
outputs.upToDateWhen { false }
// clean
doFirst {
recreateDir(processTexDir)
}
// copy
from(docsDir)
into("${processTexDir}")
include "**/*.tex"
filter(ReplaceTokens, tokens: [
'TOKEN_MOD_VERSION' : project.version.toString(),
'TOKEN_PROJECT_ROOT': project.rootDir.absolutePath,
'TOKEN_TEX_OUT_DIR' : outputTexDir.toString()
])
}
tasks.register('compileLatex') {
doFirst {
recreateDir(outputTexDir)
}
doLast {
2.times {
exec {
workingDir = processTexDir
commandLine "pdflatex",
"-file-line-error",
"-interaction=nonstopmode",
"-synctex=1",
"-output-format=pdf",
"-output-directory=${outputTexDir}",
"-shell-escape",
"fuji.tex"
println("Compile TeX once.")
}
}
println 'Finish the loop of compiling TeX.'
copy {
from("${outputTexDir}/${outputTexFile}")
into("${docsDir}/release")
}
}
}
tasks.compileLatex.dependsOn(processLatex)
/* ensure the file is not locked */
tasks.register('deleteWorldLockFile') {
outputs.upToDateWhen { false }
delete(file("$projectDir/run/world/session.lock"))
}
tasks.runServer.dependsOn(deleteWorldLockFile)
/* generate graph */
tasks.runServer.dependsOn(check)
/* copy translation files into resource directory */
tasks.register('copyTranslationFiles', Copy) {
outputs.upToDateWhen { false }
def langDir = file("$projectDir/src/main/resources/io/github/sakurawald/lang")
def translationDir = file("$projectDir/crowdin")
def sourceLanguageFile = "en_US.json"
// clean
doFirst {
delete("${translationDir}/${sourceLanguageFile}")
copy {
from("${langDir}/${sourceLanguageFile}")
into("${translationDir}")
}
recreateDir(langDir)
}
// copy
from(translationDir)
into("${langDir}")
include "**/*.json"
}
tasks.processResources.dependsOn(copyTranslationFiles)