-
Notifications
You must be signed in to change notification settings - Fork 12
/
settings.gradle
112 lines (90 loc) · 3.11 KB
/
settings.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
import groovy.json.JsonSlurper
import java.util.regex.Matcher
import java.util.regex.Pattern
pluginManagement {
repositories {
mavenLocal()
maven {
name("NyanMaven Mirror")
url("https://maven.hendrixshen.top/mirror")
}
maven {
name("Architectury")
url("https://maven.architectury.dev")
}
maven {
name("MinecraftForge")
url("https://files.minecraftforge.net/maven")
}
maven {
name("NeoForge")
url("https://maven.neoforged.net/releases")
}
maven {
name("Jitpack")
url("https://jitpack.io")
}
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "com.replaymod.preprocess": {
useModule("com.github.Fallen-Breath:preprocessor:${requested.version}")
break
}
}
}
}
}
ext {
File localPropsFile = file("${rootDir}/local.properties")
if (localPropsFile.exists()) {
Properties p = new Properties()
p.load(new FileInputStream(localPropsFile))
p.each { key, value ->
ext[key as String] = value
}
}
getOrDefault = { String key, String defaultValue ->
if (!ext.has(key)) {
return defaultValue
}
String value = ext.getProperty(key)
return value.isEmpty() ? defaultValue : value
}
}
rootProject.setName(settings.providers.gradleProperty("mod.id").get())
// Magic Core API
["common", "fabric", "forge", "neoforge"].forEach {
include("magiclib-core:${it}")
}
// Magic Game API
Map<String, Map<String, ?>> settings = file("settings.json").withReader {
new JsonSlurper().parse(it) as Map<String, Map<String, ?>>
}
Map<String, Set<String>> wrappers = new HashMap<>()
for (String module_name : settings.get("projects").keySet()) {
Map<String, ?> project_detail = settings.get("projects").get(module_name) as Map<String, ?>
String prefix = project_detail.get("prefix")
List<String> versions = project_detail.get("versions") as List<String>
String root_node_name = versions.get(0)
for (String ver : versions) {
Matcher matcher = Pattern.compile("^((?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:_\\w+)*)-(fabric|forge|neoforge|quilt)?\$").matcher(ver)
if (!matcher.matches()) {
throw new IllegalArgumentException("Invalid submodule name: ${ver}")
}
String project_name = "${module_name}:${prefix}-${ver}"
include("${project_name}")
ProjectDescriptor proj = project(":${project_name}")
proj.setProjectDir(file("${module_name}/versions/${ver}"))
proj.setBuildFileName("../${root_node_name}/build.gradle")
wrappers.computeIfAbsent(matcher.group(2), key -> new HashSet<>()).add(matcher.group(1))
}
}
for (String platform : wrappers.keySet()) {
for (String ver : wrappers.get(platform)) {
include("magiclib-wrapper:${platform}:${ver}")
}
}