22
22
Example usage (in root folder):
23
23
python scripts/update_versions.py --unity_sdk_version=<version number>
24
24
"""
25
+ import json
26
+ import glob
25
27
import os
26
28
import re
27
29
import requests
@@ -214,6 +216,35 @@ def update_readme(unity_sdk_version):
214
216
with open (readme_path , "w" ) as fout :
215
217
fout .write (replacement )
216
218
219
+ def update_json_version (json_path , new_version ):
220
+ """
221
+ Updates the version number associated with "com.google.external-dependency-manager" in a JSON file.
222
+
223
+ Args:
224
+ json_path (str): The path to the JSON file to be modified.
225
+ new_version (str): The new version number to be set.
226
+ """
227
+
228
+ with open (json_path , 'r' ) as file :
229
+ data = json .load (file )
230
+
231
+ target_key = "com.google.external-dependency-manager"
232
+ if target_key in data :
233
+ data [target_key ] = new_version
234
+
235
+ with open (json_path , 'w' ) as file :
236
+ json .dump (data , file , indent = 2 ) # Indentation for better readability
237
+
238
+ def update_export_json_files ():
239
+ jar_version = get_latest_repo_tag ('googlesamples/unity-jar-resolver' )
240
+ jar_version = jar_version .lstrip ("v" ) # jar resolver need to strip "v" from the tag
241
+ primary_path = os .path .join (os .getcwd (), 'unity_packer' , 'exports.json' )
242
+ update_json_version (primary_path , jar_version )
243
+ json_dir = os .path .join (os .getcwd (), 'unity_packer' , 'debug_single_export_json' )
244
+ for json_file in glob .glob (os .path .join (json_dir , '*.json' )):
245
+ update_json_version (json_file , jar_version )
246
+
247
+
217
248
def main (argv ):
218
249
if len (argv ) > 1 :
219
250
raise app .UsageError ('Too many command-line arguments.' )
@@ -224,6 +255,7 @@ def main(argv):
224
255
update_unity_version (FLAGS .unity_sdk_version )
225
256
update_android_deps ()
226
257
update_readme (FLAGS .unity_sdk_version )
258
+ update_export_json_files ()
227
259
228
260
if __name__ == '__main__' :
229
261
app .run (main )
0 commit comments