-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbuild.gradle
More file actions
173 lines (146 loc) · 6.27 KB
/
Copy pathbuild.gradle
File metadata and controls
173 lines (146 loc) · 6.27 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
plugins {
id "dev.architectury.loom" version "1.9-SNAPSHOT" apply false
id "architectury-plugin" version "3.4-SNAPSHOT"
id "com.github.johnrengelman.shadow" version "8.1.1" apply false
id "maven-publish"
}
ext {
getVersionSuffix = {
String versionSuffix = ""
if (System.getenv("BUILD_TAG") != null && !System.getenv("BUILD_TAG").isEmpty() && System.getenv("BUILD_RELEASE") != "true") {
versionSplit = System.getenv("BUILD_TAG").split("\\+")
versionPart = (versionSplit.length >= 2) ? versionSplit[1] : ""
if ((versionPart || !versionPart.isEmpty()) && versionPart.startsWith("alpha") || versionPart.startsWith("beta")) {
versionSuffix += "+" + versionPart
}
return versionSuffix
}
if (System.getenv("BUILD_RELEASE") != "true") {
String buildNumber = System.getenv("BUILD_ID")
versionSuffix += buildNumber != null ? ("+build." + buildNumber) : "+snapshot"
}
return versionSuffix
}
// Convert the single source of truth `minecraft_supported_versions` (a Maven
// version range) into each loader's expected range syntax.
// Fabric uses npm-semver style predicates; space-separated = AND.
// [1.21, ) -> ">=1.21"
// [1.21, 1.21.5) -> ">=1.21 <1.21.5"
minecraftFabricRange = { String rawSpec ->
String spec = rawSpec.trim()
if (!(spec.startsWith("[") || spec.startsWith("("))) {
// A bare version in Maven means ">= version".
return ">=" + spec
}
def matcher = spec =~ /^([\[(])\s*([^,\]\)]*)\s*,\s*([^,\]\)]*)\s*([\])])$/
if (!matcher.matches()) {
throw new GradleException("Cannot convert minecraft_supported_versions '${rawSpec}' to a Fabric range. " +
"Use a single Maven interval such as [1.21, ) or [1.21, 1.21.5).")
}
boolean lowerInclusive = matcher.group(1) == "["
String lower = matcher.group(2).trim()
String upper = matcher.group(3).trim()
boolean upperInclusive = matcher.group(4) == "]"
def predicates = []
if (lower) predicates << ((lowerInclusive ? ">=" : ">") + lower)
if (upper) predicates << ((upperInclusive ? "<=" : "<") + upper)
return predicates.isEmpty() ? "*" : predicates.join(" ")
}
// NeoForge consumes Maven ranges directly; only normalise whitespace.
// "[1.21, 1.21.5)" -> "[1.21,1.21.5)"
minecraftNeoForgeRange = { String rawSpec ->
return rawSpec.trim().replaceAll(/\s+/, "")
}
}
architectury {
minecraft = project.minecraft_version
}
allprojects {
group = rootProject.maven_group
version = rootProject.mod_version
}
subprojects {
// The standalone CLI module is a plain-Java application (no Minecraft / Loom / Architectury) and
// the test harness is a plain-Java JUnit project that drives an already-built jar out of process.
// Both carry their own build.gradle, so skip all Minecraft-specific wiring for them.
if (project.name.endsWith("-cli") || project.name.endsWith("-harness")) {
return
}
apply plugin: "dev.architectury.loom"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
repositories {
mavenLocal()
maven {
name "CjsahMaven"
url "https://server.cjsah.net:1002/maven/"
}
}
dependencies {
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
mappings loom.officialMojangMappings()
// incremental storage
implementation("io.github.skydynamic:incremental-storage-lib:$rootProject.incremental_storage_lib_version")
implementation("org.jetbrains.exposed:exposed-core:0.57.0")
implementation("org.jetbrains.exposed:exposed-jdbc:0.57.0")
implementation("com.h2database:h2:2.2.224")
// https://mvnrepository.com/artifact/org.quartz-scheduler/quartz
implementation("org.quartz-scheduler:quartz:2.5.0")
// lombok
compileOnly("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.projectlombok:lombok:1.18.30")
}
String versionSuffix = project.getVersionSuffix()
String fullModVersion = project.mod_version + versionSuffix
version = fullModVersion
group = project.maven_group
archivesBaseName = project.archives_name + "-mc" + project.minecraft_version + "-$project.name".replace("${mod_id}-", "")
// Access widener: merge common + platform before compiling (loom-agnostic).
apply from: rootProject.file("gradle/accesswidener.gradle")
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}
beforeEvaluate {
tasks.register('cleanBuildLibs') {
doFirst {
def libsDir = project.projectDir.toPath().resolve("build/libs").toFile()
if (libsDir.exists()) {
libsDir.listFiles().each { file ->
file.delete()
}
}
}
}
tasks.build.dependsOn(cleanBuildLibs)
tasks.remapJar.dependsOn(cleanBuildLibs)
}
afterEvaluate {
def targetLibsDir = rootProject.file("build/libs")
if (!targetLibsDir.exists()) {
targetLibsDir.mkdirs()
}
tasks.register('copyJarsToRootLibs') {
if (project.name.contains("neoforge") || project.name.contains("fabric")) {
doLast {
def sourceLibsDir = project.projectDir.toPath().resolve("build/libs").toFile()
if (sourceLibsDir.exists()) {
sourceLibsDir.listFiles().each { file ->
if (file.name.endsWith('.jar')
&& !file.name.contains('dev')
&& !file.name.contains('source')) {
ant.copy(file: file, todir: targetLibsDir)
}
}
}
}
}
}
tasks.build.finalizedBy(copyJarsToRootLibs)
tasks.remapJar.finalizedBy(copyJarsToRootLibs)
}
}