-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
124 lines (102 loc) · 3.86 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
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
project.ext["loom.platform"] = project.name.contains("neoforge") ? "neoforge" : "fabric"
boolean neoforge = project.name.contains("neoforge")
boolean fabric = project.name.contains("fabric")
group = rootProject.maven_group
version = rootProject.mod_version
apply plugin: 'dev.architectury.loom'
stonecutter.const("fabric", fabric)
stonecutter.const("neoforge", neoforge)
base {
// Set up a suffixed format for the mod jar names, e.g. `example-fabric`.
archivesName = "$rootProject.archives_name-$project.name"
}
loom {
runConfigs.all {
ideConfigGenerated(true) // Run configurations are not created for subprojects by default
runDir = "../../run" // Use a shared run folder and just create separate worlds
}
}
repositories {
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
}
dependencies {
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
if (neoforge) {
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
} else if (fabric) {
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version"
}
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.21.1:2024.11.17@zip")
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}
def neoforgeOnlyMixins = ["client.networking.NetworkRegistryMixin"]
def fabricOnlyMixins = []
processResources {
def deps = [
"version": project.version,
"id": rootProject.mod_id,
"author": rootProject.mod_author,
"description": rootProject.mod_description,
"license": rootProject.mod_license,
"github": rootProject.mod_github,
"name": rootProject.mod_name,
"logo": rootProject.mod_logo
]
inputs.property "version", project.version
inputs.property "deps", deps
filesMatching(["fabric.mod.json", "META-INF/neoforge.mods.toml", "legacy_tweaks.mixins.json"]) {
expand "version": project.version,
"id": rootProject.mod_id,
"author": rootProject.mod_author,
"description": rootProject.mod_description,
"license": rootProject.mod_license,
"github": rootProject.mod_github,
"name": rootProject.mod_name,
"logo": rootProject.mod_logo
}
if (!neoforge) exclude "META-INF/neoforge.mods.toml"
if (!fabric) exclude "fabric.mod.json"
doLast {
fileTree(dir: outputs.files.asPath, include: "legacy_tweaks.mixins.json").each { File file ->
def parse = new JsonSlurper().parse(file)
def toRemoveList = fabric ? neoforgeOnlyMixins : neoforge ? fabricOnlyMixins : [] as List<String>
for (final def mixin in toRemoveList) {
parse["mixins"].remove(mixin)
parse["client"].remove(mixin)
}
file.text = JsonOutput.prettyPrint(JsonOutput.toJson(parse))
}
}
}
def packageJar = tasks.create("packageJar", Copy.class) {
into("${rootProject.layout.buildDirectory.get()}/libs/$mod_version")
}
afterEvaluate {
packageJar.dependsOn(remapJar)
packageJar.from(remapJar.archiveFile)
build.finalizedBy(packageJar)
}