-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
163 lines (156 loc) · 7.57 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
plugins {
id("fabric-loom") version("${loom_version}") apply(false)
id("net.neoforged.moddev") version("${moddev_version}") apply(false)
id("org.cadixdev.licenser") version("${licenser_version}") apply(false)
id("me.modmuss50.mod-publish-plugin") version("${mpp_version}")
id("org.ajoberstar.grgit.service") version("${grgitservice_version}")
}
subprojects {
version = mod_version
group = mod_group
// License headers
apply(plugin: "org.cadixdev.licenser")
String licenseDir = "src/main/resources/assets/${mod_id}/license/"
license {
include("**/*.java") // Java files only
header = rootProject.project("common").file(licenseDir + "HEADER.txt")
properties {
project_name = mod_name
owner_name = mod_owner
year = java.time.LocalDate.now().getYear().toString()
}
}
if (name != "common") {
// Publishing
apply(plugin: "me.modmuss50.mod-publish-plugin")
apply(plugin: "org.ajoberstar.grgit.service")
afterEvaluate {
publishMods {
file = project.name == "fabric" ? remapJar.archiveFile : jar.archiveFile
version = mod_version
type = me.modmuss50.mpp.ReleaseType.of(release_type)
displayName = "v${mod_version}-${capsLoader(project.name)}"
modLoaders.addAll(project.property("release_mod_loaders_${project.name}").split(","))
maxRetries = 5
github {
dryRun = providers.environmentVariable("GITHUB_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("GITHUB_TOKEN")
parent project(":").tasks.named("publishGithub")
additionalFiles.from(sourcesJar.archiveFile)
}
modrinth {
dryRun = providers.environmentVariable("MODRINTH_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = modrinth_id
minecraftVersions.addAll(project.property("release_game_versions_${project.name}").split(","))
changelog = versionChangelog()
if (project.hasProperty("release_required_dep_ids_${project.name}_mr")) {
project.property("release_required_dep_ids_${project.name}_mr").split(",").each { String mrId ->
requires { id = mrId }
}
}
if (project.hasProperty("release_optional_dep_ids_${project.name}_mr")) {
project.property("release_optional_dep_ids_${project.name}_mr").split(",").each { String mrId ->
optional { id = mrId }
}
}
if (project.hasProperty("release_incompatible_dep_ids_${project.name}_mr")) {
project.property("release_incompatible_dep_ids_${project.name}_mr").split(",").each { String mrId ->
incompatible { id = mrId }
}
}
if (project.hasProperty("release_embedded_dep_ids_${project.name}_mr")) {
project.property("release_embedded_dep_ids_${project.name}_mr").split(",").each { String mrId ->
embeds { id = mrId }
}
}
// Sync Modrinth description with GitHub README
projectDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText
}
curseforge {
dryRun = providers.environmentVariable("CURSEFORGE_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
projectId = curseforge_id
projectSlug = curseforge_slug
minecraftVersions.addAll(project.property("release_game_versions_${project.name}").split(","))
changelog = versionChangelog()
if (project.hasProperty("release_required_dep_ids_${project.name}_cf")) {
project.property("release_required_dep_ids_${project.name}_cf").split(",").each { String slug ->
requires(slug)
}
}
if (project.hasProperty("release_optional_dep_ids_${project.name}_cf")) {
project.property("release_optional_dep_ids_${project.name}_cf").split(",").each { String slug ->
optional(slug)
}
}
if (project.hasProperty("release_incompatible_dep_ids_${project.name}_cf")) {
project.property("release_incompatible_dep_ids_${project.name}_cf").split(",").each { String slug ->
incompatible(slug)
}
}
if (project.hasProperty("release_embedded_dep_ids_${project.name}_cf")) {
project.property("release_embedded_dep_ids_${project.name}_cf").split(",").each { String slug ->
embeds(slug)
}
}
}
}
}
}
}
publishMods {
// This task is necessary to allow publishing files from multiple
// subprojects to a single GitHub release.
version = mod_version
type = me.modmuss50.mpp.ReleaseType.of(release_type)
github {
dryRun = providers.environmentVariable("GITHUB_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = github_repo
commitish = grgitService.service.get().grgit.branch.current().name
tagName = "v${mod_version}"
allowEmptyFiles = true
// Include compatible MC version lists in description
String versions = "## MC versions\n\n"
if (project.hasProperty("release_game_versions_fabric"))
versions = String.format("%s - Fabric: %s\n", versions,
project.property("release_game_versions_fabric"))
if (project.hasProperty("release_game_versions_neoforge"))
versions = String.format("%s - NeoForge: %s\n", versions,
project.property("release_game_versions_neoforge"))
changelog = versions + "\n\n## Changelog\n\n" + versionChangelog()
}
}
String versionChangelog() {
List<String> lines = rootProject.file("CHANGELOG.md").readLines()
StringBuilder builder = new StringBuilder()
if ("${mod_version}".startsWith(lines.get(2).substring(3))) {
for (int i = 4; i < lines.size(); i++) {
String line = lines.get(i)
if (line.isBlank()) {
// pass
} else if (line.startsWith("## ")) {
break
}
else {
if (!builder.isEmpty()) builder.append("\n")
builder.append(line)
}
}
} else {
throw new IllegalArgumentException(
String.format("Mod version '%s' does not start with changelog version '%s'",
mod_version, lines.get(2).substring(3)))
}
return builder.toString()
}
static String capsLoader(String loader) {
switch(loader) {
case "fabric": return "Fabric"
case "quilt": return "Quilt"
case "forge": return "Forge"
case "neoforge": return "NeoForge"
default: return loader
}
}