h5_package_map.H5PackageList.values().each { value -> //http://st0.meiyaapp.com/app/a0d6fce8f08fb3c5617e.zip ---> Meiya/build/tmp/h5/a0d6fce8f08fb3c5617e.zip httpDownloadFile(client, value, new File(tmp, parseFileNameFromUrl(value))) } //解压 tmp.listFiles().each { zip -> if (zip.getName().endsWith("zip")) { //Meiya/build/tmp/h5/a0d6fce8f08fb3c5617e.zip --> a0d6fce8f08fb3c5617e/* unZipIt(zip.getAbsolutePath(), tmp.getAbsolutePath())
String md5 = removeExtFromFileName(zip.getName()) File src = new File(tmp, md5) File asset_dest = new File(assets_h5, md5) if (!src.exists()) { thrownew Exception(src.getAbsolutePath() + " is not exited") } if (!src.renameTo(asset_dest)) { thrownew Exception(src.getAbsolutePath() + " rename failed.") } println "${src.getAbsolutePath()} --> ${asset_dest.getAbsolutePath()}" } } "git status".execute() "git add . --all".execute() println "git commit -m \"Update h5 to $h5_version\"" }
/** * Unzip it * @param zipFile input zip file * @param output zip file output folder */ privatevoidunZipIt(String zipFile, String outputFolder){
byte[] buffer = newbyte[1024];
try { //create output directory is not exists File folder = new File(outputFolder); if (!folder.exists()) { folder.mkdir(); }
//get the zip file content ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile)); //get the zipped file list entry ZipEntry ze = zis.getNextEntry();
while (ze != null) { String fileName = ze.getName(); File newFile = new File(outputFolder + File.separator + fileName);
if (ze.isDirectory()) { newFile.mkdirs() ze = zis.getNextEntry(); continue; }