-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
273 lines (218 loc) · 7.76 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
import me.modmuss50.mpp.ReleaseType
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id "me.modmuss50.mod-publish-plugin" version "0.8.3"
}
//Assign properties based on manifold's configuration and turn them into bindings
ext.props = getBindings(getManifold())
JavaLanguageVersion JAVA_VERSION = JavaLanguageVersion.of(props.java_version);
base {
archivesName = mod_id + "-" + mod_version + "+" + props.minecraft_version + "-fabric"
}
repositories {
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
} filter {
includeGroup "maven.modrinth"
}
}
}
loom {
splitEnvironmentSourceSets()
mods {
"circumnavigate" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
mixin {
useLegacyMixinAp = true
defaultRefmapName = "circumnavigate.refmap.json"
}
accessWidenerPath = file("src/main/resources/circumnavigate.accesswidener")
runs {
client {
//Used for debug hot-swapping fields, methods, and classes
//vmArg("-XX:+AllowEnhancedClassRedefinition")
programArgs("--width", "1280", "--height", "720", "--username", "dev")
}
}
}
afterEvaluate {
loom.runs.configureEach {
//Environment variable for enabling extra debugging features
vmArg("-Denv=dev")
//Used for debug hot-swapping mixins
vmArg("-javaagent:${ configurations.compileClasspath.find() { it.name.contains("sponge-mixin") } }")
}
}
dependencies {
//Minecraft
minecraft "com.mojang:minecraft:${props.minecraft_version}"
//Mojang mappings
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${props.parchment_version}@zip")
}
//Fabric Loader
modImplementation "net.fabricmc:fabric-loader:${props.fabric_loader_version}"
//Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${props.fabric_api_version}"
//Sodium
modImplementation "maven.modrinth:sodium:${props.sodium_version}"
//Iris Shaders
modImplementation "org.antlr:antlr4-runtime:4.13.1"
modImplementation "io.github.douira:glsl-transformer:2.0.1"
modImplementation "org.anarres:jcpp:1.4.14"
modImplementation "maven.modrinth:iris:${props.iris_shaders_version}"
//Java preprocessor
annotationProcessor "systems.manifold:manifold-preprocessor:${manifold_preprocessor_version}"
}
processResources {
filesMatching("fabric.mod.json") {
expand (
"mod_id": mod_id,
"mod_name": mod_name,
"mod_version": mod_version,
"mc_version": props.minecraft_version,
"fabric_loader_version": props.fabric_loader_version,
"java_version": props.java_version,
"fabric_api_version": props.fabric_api_version
)
}
}
publishMods {
file = remapJar.archiveFile
displayName = mod_version + "+" + props.minecraft_version + "-fabric"
changelog = new File("CHANGELOG.md").exists() ? new File("CHANGELOG.md").getText() : "Changelog not provided"
version = mod_version
type = ReleaseType.of(mod_stage)
modLoaders.add("fabric")
modrinth {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "hyNSf1Ht"
minecraftVersions.add(props.minecraft_version.toString())
requires("fabric-api")
}
curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
projectId = "990175"
minecraftVersions.add(props.minecraft_version.toString())
clientRequired = false
serverRequired = true
requires("fabric-api")
}
github {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = "FamroFexl/Circumnavigate"
commitish = "develop"
tagName = mod_version + (mod_stage != "alpha" || mod_stage != "beta") ? "" : "-" + mod_stage
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = JAVA_VERSION.asInt()
//For enabling java preprocessor on build
it.options.compilerArgs += ['-Xplugin:Manifold']
}
//References to properties can be made using the dot operator
static def getBindings(Properties props) {
Binding bindings = new Binding()
props.each { (key, value) ->
bindings.setVariable(key, value)
}
}
static def getProperties(File inFile) {
Properties outputProperties = new Properties()
//Feed properties from inFile to outputProperties
inFile.withInputStream { stream -> outputProperties.load(stream) }
return outputProperties
}
def getManifold() {
File manifoldPropertiesFile = new File("${rootDir}/build.properties")
//Get the properties pointed to by manifold
if(manifoldPropertiesFile.exists()) return getProperties(new File("versions/" + numToSemVers(Integer.parseInt(getProperties(manifoldPropertiesFile).getProperty("MC_VERSION"))) + "/gradle.properties"))
//Get default properties
else {
//List of all directories in the versions root folder
def versionsDirs = file("versions").listFiles().findAll { file -> file.isDirectory() }
Properties newProperties = getProperties(new File("${versionsDirs.last()}/gradle.properties"))
setManifold(newProperties)
return newProperties
}
}
def setManifold(Properties props) {
File manifoldPropertiesFile = file("${rootDir}/build.properties")
Properties manifoldProperties = new Properties()
//Set manifold's MC_VERSION to inFile properties
manifoldProperties.setProperty("MC_VERSION", semVersToNum(props.getProperty("minecraft_version")).toString())
//Create manifold properties file
manifoldPropertiesFile.withOutputStream { stream ->
manifoldProperties.store(stream, "Manifold preprocessor directives (DON'T CHANGE!)")
}
}
//Convert a semantic version to a number (used for preprocessor comparisons)
static def semVersToNum(String version) {
//Major must be single digit, minor must be 1-2 digits, patch must be 1-2 digits
String[] numbers = version.split("\\.");
int major = Integer.parseInt(numbers[0])
int minor = Integer.parseInt(numbers[1])
int patch = Integer.parseInt(numbers[2])
return major * 10000 + minor * 100 + patch;
}
//Convert a number to a semantic version (used to obtain the active version)
static def numToSemVers(int number) {
int major = number / 10000;
int minor = (number % 10000) / 100;
int patch = number % 100;
return String.format("%d.%d.%d", major, minor, patch);
}
gradle.projectsEvaluated {
//List of all directories in the versions root folder
def versionsDirs = file("versions").listFiles().findAll { file -> file.isDirectory() }
//Create version assignment tasks for each version
versionsDirs.each { versionDir ->
File propertiesFile = file("${versionDir}/gradle.properties")
if(propertiesFile.exists()) {
tasks.register(versionDir.name) {
group = "versions"
Properties props = getProperties(propertiesFile)
ext.props = props
setManifold(props)
}
}
else logger.error("Version " + versionDir.name + " doesn't have a gradle.properties. Ignoring.")
}
}
java {
//withSourcesJar()
sourceCompatibility = JAVA_VERSION
targetCompatibility = JAVA_VERSION
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
manifest {
attributes([
'Specification-Title' : "Fabric Loader",
'Specification-Vendor' : "FabricMC",
'Specification-Version' : props.fabric_loader_version,
'Implementation-Title' : mod_name,
'Implementation-Version' : mod_version,
'Implementation-Vendor' : "Famro Fexl",
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestamp' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : props.minecraft_version
])
}
}