-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
232 lines (190 loc) · 7.52 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
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "io.github.pacifistmc.forgix" version "1.2.6"
id "org.ajoberstar.grgit" version "4.1.0"
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
}
import groovy.json.JsonSlurper
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
// Build the list of preprocessors to use
StringBuilder sb = new StringBuilder();
sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n");
for (int i = 0; i < mcVers.size(); i++) {
String verStr = mcVers[i].replace(".", "_");
sb.append("MC_" + verStr + "=" + i.toString() + "\n");
if (mcIndex == i)
sb.append("MC_VER=" + i.toString() + "\n");
}
new File(projectDir, "build.properties").text = sb.toString()
}
static def generateForgeVersions(mc_versions) {
def json = new JsonSlurper().parseText(mc_versions) as List<String>
if (json.size() == 0) {
return "error"
}
return "[" + json[0] + "," + json[json.size() - 1] + "]"
}
project.gradle.ext.getProperties().each { prop ->
rootProject.ext.set(prop.key, prop.value)
}
writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
rootProject.versionStr = "${rootProject.mod_version}-mc${rootProject.minecraft_version}"
rootProject.compatible_forge_versions = generateForgeVersions(rootProject.compatible_minecraft_versions)
rootProject.forgix_merged_jar = "${project.archives_base_name}-${rootProject.versionStr}-${getVersionMetadata()}.jar"
compileJava {
sourceCompatibility = rootProject.java_version
targetCompatibility = rootProject.java_version
}
architectury {
minecraft = rootProject.minecraft_version
}
subprojects { p ->
apply plugin: "java"
apply plugin: "dev.architectury.loom"
apply plugin: "systems.manifold.manifold-gradle-plugin"
loom {
silentMojangMappingsLicense()
}
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
compile
mappings
// extends the shadowJar configuration
shadowMe
// have implemented dependencies automatically embedded in the final jar
implementation.extendsFrom(shadowMe)
forgeShadowMe
implementation.extendsFrom(forgeShadowMe)
shadowMe.extendsFrom(forgeShadowMe)
forgeRuntimeLibrary.extendsFrom(forgeShadowMe)
if (p != project(":common")) {
// Shadow common
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
if (findProject(":forge"))
developmentForge.extendsFrom common
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom common
compileClasspath.extendsFrom coreProjects
runtimeClasspath.extendsFrom coreProjects
if (findProject(":forge"))
developmentForge.extendsFrom coreProjects
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom coreProjects
}
}
String platformStr = ""
if (findProject(":common") && p != project(":common")) {
if (findProject(":quilt") && p == project(":quilt")) platformStr = "-fabric"
else platformStr = "-${p.name}"
}
dependencies {
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
}
modApi "com.mrmelon54.infrastructury:infrastructury${platformStr}:${rootProject.infrastructury_version}-mc${rootProject.minecraft_version}"
if (p != project(":common")) {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProduction${capitalProject(p.name)}")) { transitive false }
}
}
}
static def capitalProject(String value) {
if (value == "neoforge") return "NeoForge"
return value[0].toUpperCase() + value.substring(1)
}
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
archivesBaseName = "${rootProject.archives_base_name}-${project.name}"
version = rootProject.versionStr
group = rootProject.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url "https://maven.parchmentmc.org" }
maven { url "https://maven.mrmelon54.com/releases/" }
maven {
name = "CottonMC"
url "https://server.bbkr.space/artifactory/libs-release"
}
mavenLocal()
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = rootProject.java_version as Integer
options.compilerArgs += ["-Xplugin:Manifold"]
}
processResources {
exclude { file ->
if (file.name.contains(".${mod_id}.accesswidener") && file.name != "${accessWidenerVersion}.${mod_id}.accesswidener") {
return true
}
return false
}
}
java {
withSourcesJar()
}
}
forgix {
group = "com.mrmelon54.WirelessRedstone"
mergedJarName = rootProject.forgix_merged_jar
if (findProject(":fabric"))
fabric {
jarLocation = "build/libs/${project.archives_base_name}-fabric-${rootProject.versionStr}.jar"
}
if (findProject(":quilt"))
quilt {
jarLocation = "build/libs/${project.archives_base_name}-quilt-${rootProject.versionStr}.jar"
}
if (findProject(":forge"))
forge {
jarLocation = "build/libs/${project.archives_base_name}-forge-${rootProject.versionStr}.jar"
}
if (findProject(":neoforge"))
custom {
projectName = "neoforge"
jarLocation = "build/libs/${project.archives_base_name}-neoforge-${rootProject.versionStr}.jar"
}
removeDuplicate "com.mrmelon54.WirelessRedstone"
}
def getVersionMetadata() {
def build_id = System.getenv("GITHUB_RUN_NUMBER")
// CI builds only
if (build_id != null) {
return "build.${build_id}"
}
if (grgit != null) {
def head = grgit.head()
def id = head.abbreviatedId
// Flag the build if the build tree is not clean
if (!grgit.status().clean) {
id += "-dirty"
}
return "rev.${id}"
}
// No tracking information could be found about the build
return "unknown"
}
// Delete the merged folder when running clean
task cleanMergedJars() {
def mergedFolder = file("Merged")
if (mergedFolder.exists()) {
delete(mergedFolder)
}
}
// add cleanMergedJars to the end of the "clean" task
tasks["clean"].finalizedBy(cleanMergedJars)