forked from RelativityMC/C2ME-fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
302 lines (265 loc) · 12.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
plugins {
id 'java-library'
id 'fabric-loom' version '1.7-SNAPSHOT' apply false
id "me.champeau.jmh" version "0.7.2"
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gradleup.shadow' version '8.3.0' apply false
id 'io.github.tomtzook.gradle-cmake' version '1.2.2' apply false
}
@SuppressWarnings('unused')
static def moduleDependencies(project, List<String> depNames) {
project.dependencies {
depNames.each {
api project.dependencies.project(path: ":$it", configuration: 'namedElements')
}
}
}
configure(allprojects) {
apply plugin: 'java'
apply plugin: 'java-library'
base {
archivesName = "${project.name}-mc${project.minecraft_version}"
}
it.group = project.maven_group
it.version = project.mod_version + "." + getVersionSuffix()
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
afterEvaluate {
if (it.plugins.hasPlugin("fabric-loom")) {
migrateMappings.configure {
outputDir = project.file("src/main/java")
}
}
}
}
base {
archivesName = "${project.archives_base_name}-mc${project.minecraft_version}"
}
clean.dependsOn gradle.includedBuild('FlowSched').task(':clean')
allprojects {
repositories {
maven { url 'https://jitpack.io' }
maven {
url "https://maven.bawnorton.com/releases"
content {
includeGroup "com.bawnorton.mixinsquared"
}
}
}
}
configure (allprojects - project(":tests")) {
if (project != project(":") && project.parent != project(":")) return
apply plugin: 'fabric-loom'
apply plugin: 'maven-publish'
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
[
"fabric-networking-api-v1",
"fabric-lifecycle-events-v1",
].forEach {
modCompileOnly(fabricApi.module(it, "${project.fabric_version}"))
}
}
loom {
def file = project(":c2me-base").file("src/main/resources/c2me-base.accesswidener")
accessWidenerPath = file
enableTransitiveAccessWideners = false
// logger.lifecycle(String.format("%s: Using access widener at %s", project, file.getAbsolutePath()))
runs {
server {
ideConfigGenerated project.rootProject == project
}
client {
ideConfigGenerated project.rootProject == project
}
}
}
processResources {
inputs.property "version", project.version + "+" + project.minecraft_version
filesMatching("fabric.mod.json") {
expand "version": project.version + "+" + project.minecraft_version
}
}
jar {
from rootProject.file("LICENSE")
}
java {
withSourcesJar()
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// reproducible
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
}
configure (allprojects - project(":tests")) {
dependencies {
implementation "com.ibm.async:asyncutil:${async_util_version}"
implementation "com.electronwill.night-config:toml:${night_config_version}"
implementation "net.objecthunter:exp4j:${exp4j_version}"
implementation "org.jctools:jctools-core:${jctools_version}"
implementation annotationProcessor("com.bawnorton.mixinsquared:mixinsquared-fabric:${mixinsquared_version}")
api "com.ishland.flowsched:flowsched"
}
}
subprojects {
afterEvaluate {
afterEvaluate {
genSourcesWithFernFlower.enabled = false
genSourcesWithVineflower.enabled = false
genSourcesWithCfr.enabled = false
downloadAssets.enabled = false
}
}
}
afterEvaluate {
logger.lifecycle("Version String: ${version}")
logger.lifecycle(com.ishland.c2me.gradle.ParseGItHubActionChangelog.getChangelog())
}
dependencies {
// includeApi project(":libs")
// include project(":libs")
include implementation("com.ibm.async:asyncutil:${async_util_version}")
include implementation("com.electronwill.night-config:toml:${night_config_version}")
include implementation("com.electronwill.night-config:core:${night_config_version}")
include implementation("net.objecthunter:exp4j:${exp4j_version}")
include implementation("org.jctools:jctools-core:${jctools_version}")
include implementation(annotationProcessor("com.bawnorton.mixinsquared:mixinsquared-fabric:${mixinsquared_version}"))
include "io.reactivex.rxjava3:rxjava:${rxjava_version}"
include "org.reactivestreams:reactive-streams:${reactive_streams_version}"
// include implementation("com.ishland.flowsched:flowsched")
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
apply plugin: 'com.modrinth.minotaur'
modrinth {
token = System.getenv("MODRINTH_TOKEN") // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId = "c2me-fabric" // This can be the project ID or the slug. Either will work!
versionNumber = project.version + "+" + project.minecraft_version // You don't need to set this manually. Will fail if Modrinth has this version already
versionName = project.version + " devbuild for " + project.minecraft_version
versionType = "alpha" // This is the default -- can also be `beta` or `alpha`
uploadFile = remapJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = [project.minecraft_version] // Must be an array, even with only one version
loaders = ["fabric"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
changelog = com.ishland.c2me.gradle.ParseGItHubActionChangelog.getChangelog()
}
apply plugin: 'com.matthewprenger.cursegradle'
if (System.getenv("CURSEFORGE_TOKEN")) {
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN")
project {
id = '533097'
changelogType = "markdown"
changelog = com.ishland.c2me.gradle.ParseGItHubActionChangelog.getChangelog()
releaseType = 'alpha'
addGameVersion project.minecraft_version
addGameVersion "Fabric"
addGameVersion "Java 21"
mainArtifact(remapJar) {
displayName = project.version + " devbuild for " + project.minecraft_version
}
}
options {
forgeGradleIntegration = false
}
}
}
subprojects.forEach { remapJar.dependsOn("${it.path}:remapJar") }
dependencies {
afterEvaluate {
(subprojects - project(":tests")).forEach {
if (it.parent != project(":")) return
def projectName = it.name
api project(path: ":${projectName}", configuration: "namedElements")
include project("${projectName}:")
}
}
}
String getVersionSuffix() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty', '--broken'
standardOutput = stdout
}
stdout = stdout.toString().strip()
def suffix = ""
if (stdout.endsWith("-dirty")) {
stdout = stdout.substring(0, stdout.length() - "-dirty".length())
suffix = "-dirty"
}
if (stdout.endsWith("-broken")) {
stdout = stdout.substring(0, stdout.length() - "-broken".length())
suffix = "-broken"
}
if (stdout.indexOf('-') < 0) {
return "0" + suffix;
}
def split = stdout.split('-')
return split[split.length - 2] + suffix
}
compileJmhJava {
sourceCompatibility = JavaVersion.VERSION_22
targetCompatibility = JavaVersion.VERSION_22
}
jmh {
// includes = ['some regular expression'] // include pattern (regular expression) for benchmarks to be executed
// excludes = ['some regular expression'] // exclude pattern (regular expression) for benchmarks to be executed
iterations = 5 // Number of measurement iterations to do.
benchmarkMode = ['avgt'] // Benchmark mode. Available modes are: [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all]
batchSize = 1 // Batch size: number of benchmark method calls per operation. (some benchmark modes can ignore this setting)
fork = 2 // How many times to forks a single benchmark. Use 0 to disable forking altogether
failOnError = false // Should JMH fail immediately if any benchmark had experienced the unrecoverable error?
// forceGC = false // Should JMH force GC between iterations?
// jvm = 'myjvm' // Custom JVM to use when forking.
// jvmArgs = ['-XX:+UnlockDiagnosticVMOptions', '-XX:+LogCompilation', '-XX:+PrintAssembly', '-XX:+DebugNonSafepoints']
// jvmArgsAppend = ['Custom JVM args to use when forking (append these)']
// jvmArgsPrepend =[ 'Custom JVM args to use when forking (prepend these)']
// humanOutputFile = project.file("${project.buildDir}/reports/jmh/human.txt") // human-readable output file
resultsFile = project.file("${project.buildDir}/reports/jmh/results.txt") // results file
// operationsPerInvocation = 10 // Operations per invocation.
// benchmarkParameters = [:] // Benchmark parameters.
profilers = ['perf'] // Use profilers to collect additional data. Supported profilers: [cl, comp, gc, stack, perf, perfnorm, perfasm, xperf, xperfasm, hs_cl, hs_comp, hs_gc, hs_rt, hs_thr, async]
timeOnIteration = '2s' // Time to spend at each measurement iteration.
resultFormat = 'CSV' // Result format type (one of CSV, JSON, NONE, SCSV, TEXT)
// synchronizeIterations = true // Synchronize iterations?
threads = 1 // Number of worker threads to run with.
// threadGroups = [2,3,4] //Override thread group distribution for asymmetric benchmarks.
// timeout = '1s' // Timeout for benchmark iteration.
timeUnit = 'ns' // Output time unit. Available time units are: [m, s, ms, us, ns].
verbosity = 'NORMAL' // Verbosity mode. Available modes are: [SILENT, NORMAL, EXTRA]
warmup = '1s' // Time to spend at each warmup iteration.
warmupBatchSize = 1 // Warmup batch size: number of benchmark method calls per operation.
// warmupForks = 0 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks.
warmupIterations = 16 // Number of warmup iterations to do.
warmupMode = 'INDI' // Warmup mode for warming up selected benchmarks. Warmup modes are: [INDI, BULK, BULK_INDI].
warmupBenchmarks = ['.*Warmup'] // Warmup benchmarks to include in the run in addition to already selected. JMH will not measure these benchmarks, but only use them for the warmup.
zip64 = true // Use ZIP64 format for bigger archives
jmhVersion = '1.34' // Specifies JMH version
includeTests = true // Allows to include test sources into generate JMH jar, i.e. use it when benchmarks depend on the test classes.
duplicateClassesStrategy = DuplicatesStrategy.FAIL // Strategy to apply when encountring duplicate classes during creation of the fat jar (i.e. while executing jmhJar task)
}