-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
80 lines (68 loc) · 1.91 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
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath "com.modrinth.minotaur:Minotaur:2.+"
}
}
apply plugin: "java"
apply plugin: "com.modrinth.minotaur"
version = "2023.09.17"
static String generateCfModsList() {
List<String> cfMods = new ArrayList<>()
Map<String, String> cfNamesToIds = new HashMap<>()
new File("mods").listFiles().each {
if (it.getName().endsWith("toml") && fileContainsString(it, "curseforge")) cfMods.add(it.getName())
}
Collections.sort(cfMods)
cfMods.forEach {
File file = new File("mods/$it")
String name = getValueFromFile(file, "name").replaceAll("\"", "").replace(" (Fabric)", "")
String modId = getValueFromFile(file, "project-id")
cfNamesToIds.put(name, modId)
}
String cfModsList = ""
//noinspection GroovyAssignabilityCheck
cfNamesToIds.each {
cfModsList += "- [" + it.key + "](https://curseforge.com/projects/" + it.value + ")\n"
}
return cfModsList
}
static boolean fileContainsString(File file, String searchString) {
boolean bool = false
file.withReader { reader ->
reader.eachLine { line ->
if (line.contains(searchString)) bool = true
}
}
return bool
}
static String getValueFromFile(File file, String key) {
String val = ""
file.withReader { reader ->
reader.eachLine { line ->
if (line.startsWith(key)) val = line.split(" = ")[1]
}
}
return val
}
static String generateChangelog() {
String changelog = System.getenv().CHANGELOG
changelog += "\n\n"
changelog += "<details><summary>Mods from CurseForge</summary>"
changelog += "\n\n"
changelog += generateCfModsList()
changelog += "\n"
changelog += "</details>"
return changelog
}
tasks.modrinth.dependsOn tasks.modrinthSyncBody
modrinth {
projectId = "waffles-modpack"
gameVersions = ["1.20.1"]
loaders = ["quilt"]
changelog = generateChangelog()
uploadFile = project.file("waffle's Modpack-${version}.mrpack")
syncBodyFrom = project.file("README.md").text
}