Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
317 lines (269 loc) · 9.97 KB
/
Copy pathbuild.gradle
File metadata and controls
317 lines (269 loc) · 9.97 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import net.earthcomputer.clientcommands.buildscript.CheckLanguageFilesTask
import net.earthcomputer.clientcommands.buildscript.GenerateBuildInfoTask
import net.fabricmc.loom.task.prod.ClientProductionRunTask
plugins {
id 'net.fabricmc.fabric-loom' version "${loom_version}"
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.+'
id 'com.github.breadmoirai.github-release' version '2.4.1'
id 'checkstyle'
}
base {
archivesName = project.archives_base_name
}
repositories {
maven {
url = 'https://maven.seedfinding.com'
}
maven {
url = 'https://maven.latticg.com'
}
maven {
url = 'https://maven.xpple.dev/maven2'
}
maven {
url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1"
}
maven {
url = "https://maven.parchmentmc.org"
}
maven {
url = 'https://repo.viaversion.com'
content {
includeGroup 'com.viaversion'
}
}
}
loom {
splitEnvironmentSourceSets()
accessWidenerPath = file('src/main/resources/clientcommands.aw')
mods {
clientcommands {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
}
// Loom calls the server-side source set "main" and the client-only source set "client". Since we're primarily a
// client-side mod, the client code lives in src/main and the code that also runs on the server lives in src/common.
// The client code can access the common code, but not vice versa.
// TODO: add customization option to loom to rename the source sets instead
sourceSets {
main {
java.srcDirs = ['src/common/java']
resources.srcDirs = ['src/common/resources']
}
client {
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/resources']
}
codeGen
// Client gametests that are run against vanilla servers of older versions. These are separate from the regular
// gametests so that ViaFabricPlus is only installed for these tests.
oldServerGametest {
compileClasspath += main.output + client.output
runtimeClasspath += main.output + client.output
}
}
configurations {
includedLibrary
clientImplementation.extendsFrom includedLibrary
oldServerGametestCompileClasspath.extendsFrom clientCompileClasspath
oldServerGametestRuntimeClasspath.extendsFrom clientRuntimeClasspath
oldServerTestMatrixRuntimeOnly
}
loom {
mods {
'clientcommands-old-server-test' {
sourceSet sourceSets.oldServerGametest
}
}
}
fabricApi {
configureTests {
modId = "clientcommands-test"
enableGameTests = false
enableClientGameTests = true
createSourceSet = true
}
}
loom.runs {
oldServerClientGameTest {
inherit clientGameTest
sourceSet = sourceSets.oldServerGametest.name
runDirectory = file('build/run/oldServerClientGameTest')
systemProperties.put('fabric.client.gametest.testModResourcesPath', file('src/oldServerGametest/resources').absolutePath)
// downloaded server jars are kept outside the build directory so that they survive a clean
systemProperties.put('clientcommands.oldServerTest.cacheDir', new File(gradle.gradleUserHomeDir, 'caches/clientcommands-old-servers').absolutePath)
if (project.hasProperty('oldServerVersions')) {
// e.g. -PoldServerVersions=1.8.9,1.12.2 to only test against those versions
systemProperties.put('clientcommands.oldServerTest.versions', project.property('oldServerVersions').toString())
}
// the player name needs to be known, and the servers run in offline mode anyway
systemProperties.put('devauth.enabled', 'false')
// logs what fishing manipulation is doing, to diagnose test failures on CI
systemProperties.put('clientcommands.debugFishing', 'true')
}
}
loom.runs.configureEach {
jvmArguments.add("-enableassertions")
systemProperties.put("fabric.loom.suppressNarratorError", "true")
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
include clientImplementation("dev.xpple:clientarguments:${project.clientarguments_version}")
include implementation("dev.xpple:betterconfig-fabric:${project.betterconfig_version}")
include clientImplementation("dev.xpple:simplewaypoints:${project.simplewaypoints_version}")
includedLibrary "com.seedfinding:mc_feature:${project.seedfinding_feature_version}"
includedLibrary "com.seedfinding:mc_biome:${project.seedfinding_biome_version}"
includedLibrary "com.seedfinding:mc_core:${project.seedfinding_core_version}"
includedLibrary "com.seedfinding:mc_seed:${project.seedfinding_seed_version}"
includedLibrary "com.seedfinding:latticg:${project.latticg_version}:rt"
codeGenImplementation "com.seedfinding:latticg:${project.latticg_version}"
codeGenImplementation "org.jspecify:jspecify:1.0.0"
compileOnly 'com.demonwav.mcdev:annotations:2.0.0'
clientRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${project.devauth_version}") {
exclude group: 'net.fabricmc', module: 'fabric-loader'
}
codeGenImplementation sourceSets.client.output
// ViaFabricPlus bundles its dependencies, and its transitive dependencies would otherwise change the versions of
// Fabric Loader and Fabric API
oldServerGametestRuntimeOnly("com.viaversion:viafabricplus:${project.viafabricplus_version}") {
transitive = false
}
oldServerGametestCompileOnly("com.viaversion:viafabricplus-api:${project.viafabricplus_version}") {
transitive = false
}
oldServerGametestCompileOnly("com.viaversion:viaversion-api:${project.viaversion_version}") {
transitive = false
}
oldServerGametestImplementation "net.fabricmc:mapping-io:${project.mapping_io_version}"
// ViaVersion is otherwise only available nested inside ViaFabricPlus, which only works when the game is running
oldServerTestMatrixRuntimeOnly("com.viaversion:viaversion-api:${project.viaversion_version}") {
transitive = false
}
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
testImplementation "org.junit.jupiter:junit-jupiter:${project.junit_version}"
testImplementation "com.code-intelligence:jazzer-junit:${project.jazzer_junit_version}"
}
checkstyle {
toolVersion = project.checkstyle_version
configFile = rootProject.file("checkstyle.xml")
ignoreFailures = false
}
test {
useJUnitPlatform()
systemProperty('clientcommands.regressionTestDir', file('regressionTests').absolutePath)
}
jar {
from(configurations.includedLibrary.collect { it.isDirectory() ? it : zipTree(it) }) {
include 'com/seedfinding/**'
}
from("LICENSE")
manifest.attributes 'Main-Class': 'net.earthcomputer.clientcommands.DoubleClickMain'
}
tasks.register('deleteOldServerGameTestRunDir', Delete) {
delete loom.runs.oldServerClientGameTest.runDirectory
}
tasks.named('runOldServerClientGameTest') {
dependsOn deleteOldServerGameTestRunDir
}
// writes the GitHub Actions matrix that splits the old server gametests between parallel jobs
tasks.register('writeOldServerTestMatrix', JavaExec) {
classpath = sourceSets.oldServerGametest.runtimeClasspath + configurations.oldServerTestMatrixRuntimeOnly
mainClass = 'net.earthcomputer.clientcommands.oldservergametest.WriteTestMatrix'
args file('build/old_server_test_matrix.json').absolutePath
if (project.hasProperty('oldServerVersions')) {
systemProperty('clientcommands.oldServerTest.versions', project.property('oldServerVersions').toString())
}
}
tasks.register('generateBuildInfo', GenerateBuildInfoTask) {
outputFile = new File(temporaryDir, "build_info.json")
}
processClientResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft_version_dependency
duplicatesStrategy DuplicatesStrategy.WARN
from(sourceSets.client.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version, "mcversion": project.minecraft_version_dependency
}
from(sourceSets.client.resources.srcDirs) {
exclude "fabric.mod.json"
}
from generateBuildInfo
}
java {
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}
tasks.register("prodClient", ClientProductionRunTask) {
runDir = file("run")
jvmArgs.add("-Ddevauth.enabled=true")
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(25)
}
}
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
tasks.register('codeGen', JavaExec) {
mainClass = 'net.earthcomputer.clientcommands.codegen.CodeGenerator'
classpath = sourceSets.codeGen.runtimeClasspath
args file('src/main/java').absolutePath
enableAssertions = true
}
tasks.register('checkLanguageFiles', CheckLanguageFilesTask) {
inputDir.set(file('src/main/resources/assets/clientcommands/lang'))
}
check.dependsOn checkLanguageFiles
// read the changelog from the changelog.txt file, make sure the changelog is recent to avoid accidentally using the previous version's changelog.
def changelogFile = file('changelog.txt')
def changelogText = changelogFile.exists() && System.currentTimeMillis() - changelogFile.lastModified() <= 1000 * 60 * 60 ?
changelogFile.readLines('UTF-8').join('\n') : ''
modrinth {
token = project.hasProperty('modrinthKey') ? project.modrinthKey : System.getenv("MODRINTH_TOKEN")
projectId = 'client-commands'
uploadFile = jar
gameVersions.set(project.minecraft_version_list.split('\\s*,\\s*').toList())
loaders.set(['fabric', 'quilt'])
changelog = changelogText
dependencies {
required.project 'fabric-api'
embedded.project 'betterconfig'
embedded.project 'simplewaypoints'
}
}
tasks.modrinth.onlyIf {
!changelogText.isBlank()
}
githubRelease {
token(project.hasProperty('githubKey') ? project.githubKey : (System.getenv("GITHUB_TOKEN") ?: ''))
owner 'Earthcomputer'
repo 'clientcommands'
targetCommitish 'fabric'
releaseName "Version ${project.version} for Minecraft ${project.minecraft_version_list_presentable}"
body changelogText
releaseAssets jar.outputs
}
tasks.githubRelease.onlyIf {
!changelogText.isBlank()
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourcesJar
}
}
repositories {
// mavenLocal()
}
}