generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
221 lines (191 loc) · 6.51 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import me.modmuss50.mpp.MinecraftApi
import me.modmuss50.mpp.ReleaseType
import java.util.regex.Matcher
plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'me.modmuss50.mod-publish-plugin' version '0.4.2'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Dependencies
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "maven.modrinth:wsmlmb:${project.wsmlmb_version}"
}
processResources {
String start = version_start, end = version_end
def pattern = ~"(?:Snapshot )?(\\d+)w0?(0|[1-9]\\d*)([a-z])"
def matcher_start = pattern.matcher(start)
def matcher_end = pattern.matcher(end)
String temp
if ((temp = snapshotToRelease(matcher_start)) != null)
start = temp
if ((temp = snapshotToRelease(matcher_end)) != null)
end = temp
String version_range = ">=$start <=$end"
inputs.property "version", project.version
inputs.property "range", version_range
filesMatching("fabric.mod.json") {
expand "version": project.version, "range": version_range
}
}
tasks.withType(JavaCompile).configureEach {
//noinspection GroovyAssignabilityCheck,GroovyAccessibility
it.options.release = 17
}
java {
withSourcesJar()
withJavadocJar()
}
[jar, sourcesJar].each {
it.from("LICENSE") {
rename { "${it}_${archives_base_name}" }
}
}
remapSourcesJar {
archiveClassifier.set(archiveClassifier.get().concat("-remapped"))
}
publishMods {
def version = mod_version.split('\\+')[0]
type = release_type.toLowerCase() == 'release' ? STABLE : ReleaseType.of(release_type)
displayName = "[${version_start}-${version_end}] Stone Utils $version"
file = remapJar.archiveFile
modLoaders.add('fabric')
modLoaders.add('quilt')
changelog = file('changelog.md').text
additionalFiles.from(sourcesJar.archiveFile, remapSourcesJar.archiveFile, javadocJar.archiveFile)
modrinth {
projectId = 'NPxAgZu3'
accessToken = providers.environmentVariable('$MODRINTH_TOKEN')
announcementTitle = "Modrinth Download"
displayName = "Stone Utils $version"
minecraftVersionRange {
start = version_start
end = version_end
includeSnapshots = true
}
requires {
slug = 'fabric-api'
}
requires {
slug = 'wsmlmb'
}
}
curseforge {
projectSlug = 'stone-utils'
projectId = '853587'
accessToken = providers.environmentVariable('$CURSEFORGE_TOKEN')
announcementTitle = "Curseforge Download"
boolean matches
for (MinecraftApi.Version versionVersion in new MinecraftApi().versions.reverse()) {
if (versionVersion.id == version_start)
//noinspection GroovyUnusedAssignment
matches = true
if (matches && versionVersion.type == "release")
minecraftVersions.add versionVersion.id
if (versionVersion.id == version_end)
break
}
requires {
slug = 'fabric-api'
}
requires {
slug = 'wsmlmb'
}
}
github {
accessToken = providers.environmentVariable('$GITHUB_TOKEN')
repository = 'AnAwesomGuy/stone-utils'
announcementTitle = "Github Download"
commitish = github_branch
tagName = release_type + '/' + mod_version
}
}
private static def snapshotToRelease(Matcher matcher) {
if (matcher.matches()) {
String release
int year = Integer.parseInt(matcher.group(1))
int week = Integer.parseInt(matcher.group(2))
if (year >= 23 && week >= 40) {
release = "1.20.3"
} else if (year == 23 && week >= 31 && week <= 35) {
release = "1.20.2"
} else if (year == 23 && week >= 12 && week <= 18) {
release = "1.20"
} else if (year == 23 && week <= 7) {
release = "1.19.4"
} else if (year == 22 && week >= 42) {
release = "1.19.3"
} else if (year == 22 && week == 24) {
release = "1.19.1"
} else if (year == 22 && week >= 11 && week <= 19) {
release = "1.19"
} else if (year == 22 && week >= 3 && week <= 7) {
release = "1.18.2"
} else if (year == 21 && week >= 37 && week <= 44) {
release = "1.18"
} else if (year == 20 && week >= 45 || year == 21 && week <= 20) {
release = "1.17"
} else if (year == 20 && week >= 27 && week <= 30) {
release = "1.16.2"
} else if (year == 20 && week >= 6 && week <= 22) {
release = "1.16"
} else if (year == 19 && week >= 34) {
release = "1.15"
} else if (year == 18 && week >= 43 || year == 19 && week <= 14) {
release = "1.14"
} else if (year == 18 && week >= 30 && week <= 33) {
release = "1.13.1"
} else if (year == 17 && week >= 43 || year == 18 && week <= 22) {
release = "1.13"
} else if (year == 17 && week == 31) {
release = "1.12.1"
} else if (year == 17 && week >= 6 && week <= 18) {
release = "1.12"
} else if (year == 16 && week == 50) {
release = "1.11.1"
} else if (year == 16 && week >= 32 && week <= 44) {
release = "1.11"
} else if (year == 16 && week >= 20 && week <= 21) {
release = "1.10"
} else if (year == 16 && week >= 14 && week <= 15) {
release = "1.9.3"
} else if (year == 15 && week >= 31 || year == 16 && week <= 7) {
release = "1.9"
} else if (year == 14 && week >= 2 && week <= 34) {
release = "1.8"
} else if (year == 13 && week >= 47 && week <= 49) {
release = "1.7.4"
} else if (year == 13 && week >= 36 && week <= 43) {
release = "1.7.2"
} else if (year == 13 && week >= 16 && week <= 26) {
release = "1.6"
} else if (year == 13 && week >= 11 && week <= 12) {
release = "1.5.1"
} else if (year == 13 && week >= 1 && week <= 10) {
release = "1.5"
} else if (year == 12 && week >= 49 && week <= 50) {
release = "1.4.6"
} else if (year == 12 && week >= 32 && week <= 42) {
release = "1.4.2"
} else if (year == 12 && week >= 15 && week <= 30) {
release = "1.3.1"
} else if (year == 12 && week >= 3 && week <= 8) {
release = "1.2.1"
} else if (year == 11 && week >= 47 || year == 12 && week <= 1) {
release = "1.1"
} else return null
return String.format("%s-alpha.%s.%s.%s", release, matcher.group(1), matcher.group(2), matcher.group(3))
}
return null
}