generated from Ayydxn/Multi-ModLoaderTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
159 lines (133 loc) · 6.17 KB
/
build.gradle.kts
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
import groovy.lang.Closure
import io.github.pacifistmc.forgix.plugin.ForgixMergeExtension
import net.fabricmc.loom.api.LoomGradleExtensionAPI
plugins {
java
id("architectury-plugin") version "3.4-SNAPSHOT"
id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false
id("org.ajoberstar.grgit") version "5.2.2"
id("io.github.pacifistmc.forgix") version "1.2.9"
}
// Sets which platforms native libraries from LWJGL we will use.
rootProject.setProperty("lwjgl_natives", Pair(System.getProperty("os.name")!!, System.getProperty("os.arch")!!).let { (name, arch) ->
when {
arrayOf("Linux", "SunOS", "Unit").any { name.startsWith(it) } ->
if (arrayOf("arm", "aarch64").any { arch.startsWith(it) })
"natives-linux${if (arch.contains("64") || arch.startsWith("armv8")) "-arm64" else "-arm32"}"
else if (arch.startsWith("ppc"))
"natives-linux-ppc64le"
else if (arch.startsWith("riscv"))
"natives-linux-riscv64"
else
"natives-linux"
arrayOf("Mac OS X", "Darwin").any { name.startsWith(it) } ->
"natives-macos${if (arch.startsWith("aarch64")) "-arm64" else ""}"
arrayOf("Windows").any { name.startsWith(it) } ->
if (arch.contains("64"))
"natives-windows${if (arch.startsWith("aarch64")) "-arm64" else ""}"
else
"natives-windows-x86"
else ->
throw Error("Unrecognized or unsupported platform. Please set the \"lwjgl_natives\" property manually")
}
})
architectury {
minecraft = rootProject.property("minecraft_version").toString()
}
@Suppress("UNCHECKED_CAST")
configure<ForgixMergeExtension> {
group = "${rootProject.property("maven_group")}.iridium"
mergedJarName = "iridium-${getIridiumVersionString()}.jar"
outputDir = "build/forgix"
fabric(closureOf<ForgixMergeExtension.FabricContainer> {
jarLocation = "build/libs/iridium-${getIridiumVersionString()}-fabric.jar"
} as Closure<ForgixMergeExtension.FabricContainer>)
custom(closureOf<ForgixMergeExtension.CustomContainer> {
projectName = "neoforge"
jarLocation = "build/libs/iridium-${getIridiumVersionString()}-neoforge.jar"
} as Closure<ForgixMergeExtension.CustomContainer>)
}
subprojects {
apply(plugin = "dev.architectury.loom")
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
loom.silentMojangMappingsLicense()
dependencies {
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft_version")}")
@Suppress("UnstableApiUsage")
"mappings"(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.property("minecraft_version")}:${rootProject.property("parchment_version")}@zip")
})
}
tasks.processResources {
val expandProps = mapOf(
"name" to rootProject.property("mod_name"),
"version" to getIridiumVersionString(),
"description" to rootProject.property("mod_description"),
"id" to rootProject.property("mod_id"),
"author" to rootProject.property("mod_author"),
"icon_path" to rootProject.property("icon_path"),
"issue_tracker_url" to rootProject.property("issue_tracker_url"),
"license" to rootProject.property("license"),
"minecraft_version" to rootProject.property("minecraft_version"),
"minecraft_version_range" to rootProject.property("minecraft_version_range"),
"architectury_version" to rootProject.property("architectury_version"),
"architectury_version_range" to rootProject.property("architectury_version_range"),
"fabric_loader_version" to rootProject.property("fabric_loader_version"),
"fabric_version" to rootProject.property("fabric_api_version"),
"neoforge_version" to rootProject.property("neoforge_version"),
"neoforge_version_range" to rootProject.property("neoforge_version_range"),
"yacl_version" to rootProject.property("yacl_version")
)
inputs.properties(expandProps)
filesMatching(listOf("pack.mcmeta", "fabric.mod.json", "META-INF/neoforge.mods.toml", "*.mixins.json")) {
expand(expandProps)
}
}
}
allprojects {
apply(plugin = "java")
apply(plugin = "architectury-plugin")
apply(plugin = "maven-publish")
base.archivesName.set(rootProject.property("archives_base_name").toString())
version = getIridiumVersionString()
group = rootProject.property("maven_group").toString()
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("https://maven.neoforged.net/releases/") {
name = "NeoForged"
}
maven("https://maven.isxander.dev/releases") {
name = "Xander's Maven"
}
maven("https://maven.parchmentmc.org") {
name = "ParchmentMC"
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release = 21
}
java {
withSourcesJar()
}
}
fun getIridiumVersionString(): String {
val stringBuilder = StringBuilder()
val isADistributionBuild = project.hasProperty("build.distribution")
val buildID = System.getenv("GITHUB_RUN_NUMBER")
stringBuilder.append("${rootProject.property("mod_version")}-mc${rootProject.property("minecraft_version")}")
if (!isADistributionBuild) {
stringBuilder.append("+snapshot")
if (buildID != null) {
stringBuilder.append("-build.${buildID}")
} else {
stringBuilder.append("-local")
}
}
return stringBuilder.toString()
}