@@ -47,6 +47,247 @@ pub struct ForgeVersionClassifiers {
47
47
pub src_zip : Option < ForgeVersionClassifier > ,
48
48
}
49
49
50
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
51
+ #[ serde( deny_unknown_fields) ]
52
+ pub struct ForgeVersionArguments {
53
+ pub game : Vec < String > ,
54
+ pub jvm : Option < Vec < String > > ,
55
+ }
56
+
57
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
58
+ #[ serde( deny_unknown_fields) ]
59
+ pub struct ForgeVersionLibraryArtifact {
60
+ pub path : String ,
61
+ pub url : String ,
62
+ pub sha1 : String ,
63
+ pub size : u64 ,
64
+ }
65
+
66
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
67
+ #[ serde( deny_unknown_fields) ]
68
+ pub struct ForgeVersionLibraryDownloads {
69
+ pub artifact : ForgeVersionLibraryArtifact ,
70
+ }
71
+
72
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
73
+ #[ serde( deny_unknown_fields) ]
74
+ pub struct ForgeVersionLibrary {
75
+ pub name : String ,
76
+ pub downloads : ForgeVersionLibraryDownloads ,
77
+ }
78
+
79
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
80
+ #[ serde( deny_unknown_fields) ]
81
+ pub struct ForgeVersionLoggingFile {
82
+ pub id : String ,
83
+ pub sha1 : String ,
84
+ pub size : u64 ,
85
+ pub url : String ,
86
+ }
87
+
88
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
89
+ #[ serde( deny_unknown_fields) ]
90
+ pub struct ForgeVersionLoggingClient {
91
+ pub argument : String ,
92
+ pub file : ForgeVersionLoggingFile ,
93
+ #[ serde( rename = "type" ) ]
94
+ pub client_type : String ,
95
+ }
96
+
97
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
98
+ #[ serde( deny_unknown_fields) ]
99
+ pub struct ForgeVersionLogging {
100
+ pub client : Option < ForgeVersionLoggingClient > ,
101
+ }
102
+
103
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
104
+ #[ serde( rename_all = "camelCase" , deny_unknown_fields) ]
105
+ pub struct ForgeVersion {
106
+ #[ serde( rename = "_comment_" ) ]
107
+ pub comment : Option < Vec < String > > ,
108
+ pub id : String ,
109
+ pub time : String ,
110
+ pub release_time : String ,
111
+ #[ serde( rename = "type" ) ]
112
+ pub release_type : String ,
113
+ pub main_class : String ,
114
+ pub inherits_from : String ,
115
+ pub logging : ForgeVersionLogging ,
116
+ pub arguments : Option < ForgeVersionArguments > ,
117
+ pub libraries : Vec < ForgeVersionLibrary > ,
118
+ pub minecraft_arguments : Option < String > ,
119
+ }
120
+
121
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
122
+ #[ serde( deny_unknown_fields) ]
123
+ pub struct ForgeInstallerDataInfo {
124
+ pub client : String ,
125
+ pub server : String ,
126
+ }
127
+
128
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
129
+ #[ serde( deny_unknown_fields, rename_all = "SCREAMING_SNAKE_CASE" ) ]
130
+ pub struct ForgeInstallerData {
131
+ pub mappings : Option < ForgeInstallerDataInfo > ,
132
+ pub mojmaps : Option < ForgeInstallerDataInfo > ,
133
+ pub merged_mappings : Option < ForgeInstallerDataInfo > ,
134
+ pub binpatch : Option < ForgeInstallerDataInfo > ,
135
+ pub mc_unpacked : Option < ForgeInstallerDataInfo > ,
136
+ pub mc_slim : Option < ForgeInstallerDataInfo > ,
137
+ pub mc_slim_sha : Option < ForgeInstallerDataInfo > ,
138
+ pub mc_extra : Option < ForgeInstallerDataInfo > ,
139
+ pub mc_extra_sha : Option < ForgeInstallerDataInfo > ,
140
+ pub mc_srg : Option < ForgeInstallerDataInfo > ,
141
+ pub patched : Option < ForgeInstallerDataInfo > ,
142
+ pub patched_sha : Option < ForgeInstallerDataInfo > ,
143
+ pub mcp_version : Option < ForgeInstallerDataInfo > ,
144
+ pub mc_data : Option < ForgeInstallerDataInfo > ,
145
+ pub mc_data_sha : Option < ForgeInstallerDataInfo > ,
146
+ }
147
+
148
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
149
+ #[ serde( deny_unknown_fields) ]
150
+ pub struct ForgeInstallerProcessor {
151
+ pub sides : Option < Vec < String > > ,
152
+ pub jar : String ,
153
+ pub classpath : Vec < String > ,
154
+ pub args : Vec < String > ,
155
+ pub outputs : Option < HashMap < String , String > > ,
156
+ }
157
+
158
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
159
+ #[ serde( deny_unknown_fields) ]
160
+ pub struct ForgeLegacyLogging { }
161
+
162
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
163
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
164
+ pub struct ForgeLegacyInstall {
165
+ pub profile_name : String ,
166
+ pub target : String ,
167
+ pub path : String ,
168
+ pub version : String ,
169
+ pub file_path : String ,
170
+ pub welcome : String ,
171
+ pub minecraft : String ,
172
+ pub mirror_list : String ,
173
+ pub logo : String ,
174
+ pub mod_list : Option < String > ,
175
+ }
176
+
177
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
178
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
179
+ pub struct ForgeLegacyLibraryNatives {
180
+ pub linux : Option < String > ,
181
+ pub osx : Option < String > ,
182
+ pub windows : Option < String > ,
183
+ }
184
+
185
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
186
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
187
+ pub struct ForgeLegacyLibraryExtract {
188
+ pub exclude : Vec < String > ,
189
+ }
190
+
191
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
192
+ #[ serde( rename_all = "camelCase" , deny_unknown_fields) ]
193
+ pub struct ManifestRule {
194
+ pub action : String ,
195
+ pub os : Option < ManifestRuleOS > ,
196
+ }
197
+
198
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
199
+ #[ serde( rename_all = "camelCase" , deny_unknown_fields) ]
200
+ pub struct ManifestRuleOS {
201
+ pub name : Option < String > ,
202
+ pub version : Option < String > ,
203
+ pub arch : Option < String > ,
204
+ }
205
+
206
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
207
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
208
+ pub struct ForgeLegacyLibrary {
209
+ pub name : String ,
210
+ pub url : Option < String > ,
211
+ pub serverreq : Option < bool > ,
212
+ pub clientreq : Option < bool > ,
213
+ pub checksums : Option < Vec < String > > ,
214
+ pub natives : Option < ForgeLegacyLibraryNatives > ,
215
+ pub extract : Option < ForgeLegacyLibraryExtract > ,
216
+ pub rules : Option < Vec < ManifestRule > > ,
217
+ pub comment : Option < String > ,
218
+ }
219
+
220
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
221
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
222
+ pub struct ForgeLegacyVersionInfo {
223
+ pub id : String ,
224
+ pub time : String ,
225
+ pub release_time : String ,
226
+ #[ serde( rename = "type" ) ]
227
+ pub release_type : String ,
228
+ pub minecraft_arguments : String ,
229
+ pub minimum_launcher_version : Option < u64 > ,
230
+ pub assets : Option < String > ,
231
+ pub main_class : String ,
232
+ pub libraries : Vec < ForgeLegacyLibrary > ,
233
+ pub inherits_from : Option < String > ,
234
+ pub process_arguments : Option < String > ,
235
+ pub jar : Option < String > ,
236
+ pub logging : Option < ForgeLegacyLogging > ,
237
+ }
238
+
239
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
240
+ #[ serde( deny_unknown_fields) ]
241
+ pub struct ForgeLegacyOptional {
242
+ pub name : String ,
243
+ pub client : bool ,
244
+ pub server : bool ,
245
+ pub default : bool ,
246
+ pub inject : bool ,
247
+ pub desc : String ,
248
+ pub url : String ,
249
+ pub artifact : String ,
250
+ pub maven : String ,
251
+ }
252
+
253
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
254
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
255
+ pub struct ForgeLegacyInstallerManifest {
256
+ #[ serde( rename = "_comment_" ) ]
257
+ pub comment : Option < Vec < String > > ,
258
+ pub install : ForgeLegacyInstall ,
259
+ pub version_info : ForgeLegacyVersionInfo ,
260
+ pub optionals : Option < Vec < ForgeLegacyOptional > > ,
261
+ }
262
+
263
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
264
+ #[ serde( deny_unknown_fields, rename_all = "camelCase" ) ]
265
+ pub struct ForgeInstallerManifest {
266
+ #[ serde( rename = "_comment_" ) ]
267
+ pub comment : Option < Vec < String > > ,
268
+ pub spec : u64 ,
269
+ pub profile : String ,
270
+ pub version : String ,
271
+ pub path : Option < String > ,
272
+ pub minecraft : String ,
273
+ pub server_jar_path : Option < String > ,
274
+ pub icon : Option < String > ,
275
+ pub json : String ,
276
+ pub logo : String ,
277
+ pub mirror_list : Option < String > ,
278
+ pub welcome : String ,
279
+ pub data : ForgeInstallerData ,
280
+ pub processors : Vec < ForgeInstallerProcessor > ,
281
+ pub libraries : Vec < ForgeVersionLibrary > ,
282
+ }
283
+
284
+ #[ derive( Deserialize , Serialize , Clone , Debug ) ]
285
+ #[ serde( untagged) ]
286
+ pub enum ForgeInstallerManifestVersion {
287
+ Legacy ( Box < ForgeLegacyInstallerManifest > ) ,
288
+ Modern ( Box < ForgeInstallerManifest > ) ,
289
+ }
290
+
50
291
#[ cfg( test) ]
51
292
mod tests {
52
293
#[ test]
@@ -80,7 +321,37 @@ mod tests {
80
321
& std:: fs:: read_to_string ( version_path) . unwrap ( ) ,
81
322
) ;
82
323
if let Err ( e) = version {
83
- panic ! ( "Failed to deserialize version {}: {:?}" , forge_version, e) ;
324
+ panic ! (
325
+ "Failed to deserialize file manifest of version {}: {:?}" ,
326
+ forge_version, e
327
+ ) ;
328
+ }
329
+ let installer_path =
330
+ meta_dir. join ( format ! ( "installer_manifests/{}.json" , forge_version) ) ;
331
+ if installer_path. exists ( ) {
332
+ let installer = serde_json:: from_str :: < super :: ForgeInstallerManifestVersion > (
333
+ & std:: fs:: read_to_string ( & installer_path) . unwrap ( ) ,
334
+ ) ;
335
+ if let Err ( e) = installer {
336
+ panic ! (
337
+ "Failed to deserialize installer manifest of version {}: {:?}" ,
338
+ forge_version, e
339
+ ) ;
340
+ }
341
+ }
342
+
343
+ let version_path =
344
+ meta_dir. join ( format ! ( "version_manifests/{}.json" , forge_version) ) ;
345
+ if version_path. exists ( ) {
346
+ let version = serde_json:: from_str :: < super :: ForgeVersion > (
347
+ & std:: fs:: read_to_string ( version_path) . unwrap ( ) ,
348
+ ) ;
349
+ if let Err ( e) = version {
350
+ panic ! (
351
+ "Failed to deserialize manifest for version {}: {:?}" ,
352
+ forge_version, e
353
+ ) ;
354
+ }
84
355
}
85
356
}
86
357
}
0 commit comments