-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
345 lines (304 loc) · 11.1 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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import dev.lukebemish.codecextras.gradle.FormatJmhOutput
plugins {
alias cLibs.plugins.conventions.java
id 'signing'
id 'dev.lukebemish.managedversioning'
}
group = 'dev.lukebemish'
managedVersioning {
versionFile.set project.file('version.properties')
versionPRs()
versionSnapshots()
gitHubActions {
snapshot {
prettyName.set 'Snapshot'
workflowDispatch.set(true)
onBranches.add 'main'
gradleJob {
buildCache()
cacheReadOnly.set false
javaVersion.set '21'
name.set 'build'
gradlew 'Build', 'build'
gradlew 'Publish', 'publish'
mavenSnapshot('github')
}
}
benchmark {
prettyName.set 'Benchmark'
workflowDispatch.set(true)
gradleJob {
buildCache()
javaVersion.set '21'
name.set 'build'
gradlew 'JMH', 'jmhResults'
step {
name.set 'Record JMH Output'
run.set 'cat build/reports/jmh/results.md >> $GITHUB_STEP_SUMMARY'
}
}
}
release {
prettyName.set 'Release'
workflowDispatch.set(true)
gradleJob {
buildCache()
javaVersion.set '21'
name.set 'build'
step {
setupGitUser()
}
readOnly.set false
gradlew 'Tag Release', 'tagRelease'
gradlew 'Build', 'build'
step {
run.set 'git push && git push --tags'
}
recordVersion 'Record Version', 'version'
dependencySubmission()
}
gradleJob {
buildCache()
javaVersion.set '21'
name.set 'publish'
needs.add('build')
tag.set('${{needs.build.outputs.version}}')
gradlew 'Publish', 'publish', 'closeAndReleaseSonatypeStagingRepository'
sign()
mavenCentral()
mavenStaging('github')
}
}
build_pr {
prettyName.set 'Build PR'
pullRequest.set(true)
gradleJob {
javaVersion.set '21'
name.set 'build'
gradlew 'Build', 'build'
gradlew 'Publish', 'publish'
pullRequestArtifact()
}
}
publish_pr {
prettyName.set 'Publish PR'
publishPullRequestAction(
'github',
"${project.group.replace('.', '/')}/${project.name}",
'Build PR'
)
}
}
}
managedVersioning.apply()
println "Building: $version"
sourceSets {
minecraft {}
minecraftFabric {}
jmh {}
}
configurations {
testNeoforgeRuntimeClasspath.extendsFrom minecraftRuntimeClasspath
testFabricRuntimeClasspath.extendsFrom minecraftFabricRuntimeClasspath
testFabricToRemapRuntimeClasspath.extendsFrom minecraftFabricToRemapRuntimeClasspath
testNeoforgeCompileClasspath.extendsFrom minecraftCompileClasspath
testFabricCompileClasspath.extendsFrom minecraftFabricCompileClasspath
testFabricToRemapCompileClasspath.extendsFrom minecraftFabricToRemapCompileClasspath
runtimeModClasses {
canBeConsumed = true
canBeResolved = false
}
}
artifacts {
sourceSets.main.output.classesDirs.each { file ->
add(configurations.runtimeModClasses.name, file) {
builtBy tasks.classes
}
}
add(configurations.runtimeModClasses.name, sourceSets.main.output.resourcesDir) {
builtBy tasks.processResources
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withSourcesJar()
withJavadocJar()
registerFeature("minecraft") {
usingSourceSet sourceSets.minecraft
withSourcesJar()
withJavadocJar()
capability(project.group as String, "$project.name-minecraft", project.version as String)
capability(project.group as String, "$project.name-minecraft-common", project.version as String)
// Old name
capability(project.group as String, "$project.name-stream", project.version as String)
withJavadocJar()
withSourcesJar()
}
registerFeature("minecraftFabric") {
usingSourceSet sourceSets.minecraftFabric
capability(project.group as String, "$project.name-minecraft", project.version as String)
capability(project.group as String, "$project.name-minecraft-fabric", project.version as String)
// Old name
capability(project.group as String, "$project.name-stream", project.version as String)
capability(project.group as String, "$project.name-stream-intermediary", project.version as String)
withJavadocJar()
withSourcesJar()
}
registerFeature("minecraftNeoforge") {
usingSourceSet sourceSets.minecraftNeoforge
capability(project.group as String, "$project.name-minecraft", project.version as String)
capability(project.group as String, "$project.name-minecraft-neoforge", project.version as String)
// Old name
capability(project.group as String, "$project.name-stream", project.version as String)
withJavadocJar()
withSourcesJar()
}
}
repositories {
mavenCentral()
maven {
name = 'Minecraft Libraries'
url = 'https://libraries.minecraft.net/'
}
}
dependencies {
api 'com.mojang:datafixerupper:8.0.16'
api 'org.slf4j:slf4j-api:2.0.1'
jmhCompileOnly cLibs.bundles.compileonly
jmhImplementation project(':')
jmhImplementation 'org.openjdk.jmh:jmh-core:1.37'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
jmhRuntimeOnly 'org.ow2.asm:asm:9.5'
testCompileOnly cLibs.bundles.compileonly
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-params:5.9.2'
compileOnly 'com.electronwill.night-config:core:3.6.4'
compileOnly 'com.electronwill.night-config:toml:3.6.4'
compileOnly 'blue.endless:jankson:1.2.2'
compileOnly 'org.ow2.asm:asm:9.5'
testImplementation 'com.electronwill.night-config:core:3.6.4'
testImplementation 'com.electronwill.night-config:toml:3.6.4'
testImplementation 'blue.endless:jankson:1.2.2'
testImplementation 'org.ow2.asm:asm:9.5'
annotationProcessor 'dev.lukebemish.autoextension:autoextension:0.1.1'
compileOnly 'dev.lukebemish.autoextension:autoextension:0.1.1'
minecraftApi project(':')
minecraftCompileOnly cLibs.bundles.compileonly
minecraftAnnotationProcessor cLibs.bundles.annotationprocessor
minecraftFabricCompileOnly cLibs.bundles.compileonly
minecraftFabricAnnotationProcessor cLibs.bundles.annotationprocessor
minecraftNeoforgeCompileOnly cLibs.bundles.compileonly
minecraftNeoforgeAnnotationProcessor cLibs.bundles.annotationprocessor
minecraftFabricApi project(':')
minecraftNeoforgeApi project(':')
testNeoforgeCompileOnly sourceSets.minecraftNeoforge.output
testNeoforgeCompileOnly sourceSets.minecraft.output
testFabricCompileOnly sourceSets.minecraftFabric.output
testFabricCompileOnly sourceSets.minecraft.output
testCommonCompileOnly(project(':')) {
capabilities {
requireCapability 'dev.lukebemish:codecextras-minecraft-common'
}
}
modTestFabricImplementation libs.fabric.loader
modTestFabricLocalImplementation libs.fabric.api
modTestFabricLocalImplementation libs.modmenu
modMinecraftFabricImplementation libs.fabric.loader
modMinecraftFabricImplementation libs.fabric.api
modMinecraftFabricLocalImplementation libs.modmenu
}
['minecraftJar', 'minecraftFabricJar', 'minecraftNeoforgeJar', 'jar'].each {
tasks.named(it, Jar) {
manifest {
attributes(
'Specification-Version' : project.version,
'Implementation-Version' : project.version,
'Implementation-Commit-Time': managedVersioning.timestamp.get(),
'Implementation-Commit' : managedVersioning.hash.get()
)
}
}
}
tasks.named('jar', Jar) {
manifest {
attributes(
'Automatic-Module-Name': project.group + '.' + project.name,
'FMLModType' : 'LIBRARY'
)
}
}
['minecraftJar', 'minecraftFabricJar', 'minecraftNeoforgeJar'].each {
tasks.named(it, Jar) {
manifest {
attributes(
'Automatic-Module-Name' : project.group + '.' + project.name + '.minecraft',
'Implementation-Minecraft-Version' : libs.versions.minecraft.get()
)
}
}
}
tasks.register('jmh', JavaExec) {
group = 'benchmark'
dependsOn sourceSets.jmh.output
mainClass = 'org.openjdk.jmh.Main'
systemProperty 'jmh.executor', 'VIRTUAL'
systemProperty 'jmh.blackhole.mode', 'COMPILER'
args '-rf', 'json', '-rff', 'build/reports/jmh/results.json'
classpath = sourceSets.jmh.runtimeClasspath
doFirst {
mkdir('build/reports/jmh')
}
outputs.file('build/reports/jmh/results.json')
}
tasks.register('jmhResults', FormatJmhOutput) {
group = 'benchmark'
dependsOn tasks.jmh
jmhResults.set project.file('build/reports/jmh/results.json')
formattedResults.set project.file('build/reports/jmh/results.md')
}
tasks.compileJava {
options.compilerArgs += [
'-Aautoextension.name=CodecExtras',
"-Aautoextension.version=${version}".toString()
]
}
['processResources', 'processMinecraftResources', 'processMinecraftFabricResources', 'processMinecraftNeoforgeResources'].each {
tasks.named(it, ProcessResources) {
var version = project.version.toString()
var minecraftVersion = libs.versions.minecraft.get()
inputs.property "version", version
inputs.property "minecraft_version", minecraftVersion
filesMatching(["fabric.mod.json", "META-INF/neoforge.mods.toml"]) {
expand([
"version": version,
"minecraft_version": minecraftVersion
])
}
}
}
test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
events = ['passed', 'failed', 'skipped']
}
}
publishing {
publications {
mavenJava(MavenPublication) {
managedVersioning.publishing.sign(signing, it)
managedVersioning.publishing.pom(it, 'codecextras', 'LGPL-3.0-only')
pom {
name = 'codecextras'
description = 'Various extensions and utilities for Mojang\'s DFU library'
}
from components.java
}
}
}
managedVersioning.publishing.mavenStaging(publishing)
managedVersioning.publishing.mavenCentral()
managedVersioning.publishing.mavenPullRequest(publishing)
managedVersioning.publishing.mavenSnapshot(publishing)