1b8a72a62Sopenharmony_ci/* 2b8a72a62Sopenharmony_ci * Copyright (c) 2019-2021 Huawei Device Co., Ltd. 3b8a72a62Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4b8a72a62Sopenharmony_ci * you may not use this file except in compliance with the License. 5b8a72a62Sopenharmony_ci * You may obtain a copy of the License at 6b8a72a62Sopenharmony_ci * 7b8a72a62Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8b8a72a62Sopenharmony_ci * 9b8a72a62Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10b8a72a62Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11b8a72a62Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12b8a72a62Sopenharmony_ci * See the License for the specific language governing permissions and 13b8a72a62Sopenharmony_ci * limitations under the License. 14b8a72a62Sopenharmony_ci */ 15b8a72a62Sopenharmony_ci 16b8a72a62Sopenharmony_ciuse commands for package hap or app. 17b8a72a62Sopenharmony_ci 18b8a72a62Sopenharmony_ciCONSTRAINT: 19b8a72a62Sopenharmony_ci1.When the app depends on a hap, you need to wait the hap has been packaged, 20b8a72a62Sopenharmony_ci It can be controlled according to the return value of the command execution. 21b8a72a62Sopenharmony_ci2.If the same command appears many times in a command, take the last value that appears. 22b8a72a62Sopenharmony_ci For example: --mode hap --mode app 23b8a72a62Sopenharmony_ci the mode value is app. 24b8a72a62Sopenharmony_ci3.If there are several parameters in the same command, take the first value. 25b8a72a62Sopenharmony_ci For example: --mode hap app 26b8a72a62Sopenharmony_ci the mode value is hap. 27b8a72a62Sopenharmony_ci4.Path cannot start with '--', to avoid conflict with the instruction. 28b8a72a62Sopenharmony_ci5.Command must be lowercase(such as:--mode), and file's suffix is case insensitive, 29b8a72a62Sopenharmony_ci but json's filename must be config.json and index's filename must be resources.index. 30b8a72a62Sopenharmony_ci6.Absolute paths is recommended. 31b8a72a62Sopenharmony_ci7.After package a hap, files under resources/ will put into assets/entry/resources/ directory, 32b8a72a62Sopenharmony_ci files under lib/ will be putted into libs/ directory, 33b8a72a62Sopenharmony_ci files under maple-so/ will be putted into maple/ directory, 34b8a72a62Sopenharmony_ci file of resources.index will be putted into assets/entry/ directory. 35b8a72a62Sopenharmony_ci8.maple so input method have a tentative plan which can support two input methods. 36b8a72a62Sopenharmony_ci If "maple-so-path" is valid, "maple-so-dir" will not be used. 37b8a72a62Sopenharmony_ci The input method of "maple-so-path" will be discarded later. 38b8a72a62Sopenharmony_ci9.In app package mode, signature and certificate may be resource files later, 39b8a72a62Sopenharmony_ci so parameters are reserved now. 40b8a72a62Sopenharmony_ci 41b8a72a62Sopenharmony_ciHAP USAGE: 42b8a72a62Sopenharmony_cijava -jar app_packing_tool.jar --mode <option> --json-path <option> --maple-so-path [option] 43b8a72a62Sopenharmony_ci--profile-path [option] --maple-so-dir [option] --dex-path [option] --lib-path [option] --assets-path [option] 44b8a72a62Sopenharmony_ci--resources-path [option] --shell-apk-path [option] --index-path [option] --out-path <option> --force [option] 45b8a72a62Sopenharmony_ci 46b8a72a62Sopenharmony_ciHAP MODE OPTIONS: 47b8a72a62Sopenharmony_ci --mode not null must be hap. 48b8a72a62Sopenharmony_ci --json-path not null config.json path. 49b8a72a62Sopenharmony_ci --profile-path CAPABILITY.profile path. 50b8a72a62Sopenharmony_ci --maple-so-path maple-so/ path. 51b8a72a62Sopenharmony_ci --maple-so-dir maple so path must end with .so, if has more than one so, 52b8a72a62Sopenharmony_ci use comma(,) to separate. 53b8a72a62Sopenharmony_ci --dex-path 1.dex path must end with .dex, if has more than one dex, 54b8a72a62Sopenharmony_ci use comma(,) to separate. 55b8a72a62Sopenharmony_ci 2.dex path also can be directory path. 56b8a72a62Sopenharmony_ci --abc-path 1.abc path must end with .abc, if has more than one abc, 57b8a72a62Sopenharmony_ci use comma(,) to separate. 58b8a72a62Sopenharmony_ci 2.abc path also can be directory path. 59b8a72a62Sopenharmony_ci --lib-path lib/ path. 60b8a72a62Sopenharmony_ci --assets-path assets/ path. 61b8a72a62Sopenharmony_ci --resources-path resources path. 62b8a72a62Sopenharmony_ci --shell-apk-path 1.shell apk path can end with .apk, if has more than one apk, 63b8a72a62Sopenharmony_ci use comma(,) to separate. 64b8a72a62Sopenharmony_ci 2.shell apk path also can be directory path. 65b8a72a62Sopenharmony_ci --index-path resources.index path. 66b8a72a62Sopenharmony_ci --out-path not null target hap binary path,must end with .hap. 67b8a72a62Sopenharmony_ci --force default false; if true, force delete destination 68b8a72a62Sopenharmony_ci out file if exists. 69b8a72a62Sopenharmony_ci 70b8a72a62Sopenharmony_ciHAR USAGE: 71b8a72a62Sopenharmony_cijava -jar app_packing_tool.jar --mode <options> --json-path <option> 72b8a72a62Sopenharmony_ci--jar-path <option> --lib-path [option] --assets-path [option] 73b8a72a62Sopenharmony_ci--resources-path [option] --out-path <option> --force [option] 74b8a72a62Sopenharmony_ciOPTIONS: 75b8a72a62Sopenharmony_ci --mode not null must be har. 76b8a72a62Sopenharmony_ci --json-path not null config.json path. 77b8a72a62Sopenharmony_ci --jar-path not null 1.jar path must end with .jar, 78b8a72a62Sopenharmony_ci if has more than one jar, use comma(,) to separate; 79b8a72a62Sopenharmony_ci 2.jar path also can be directory path. 80b8a72a62Sopenharmony_ci --lib-path lib/ path. 81b8a72a62Sopenharmony_ci --resources-path not null resources/ path. 82b8a72a62Sopenharmony_ci --txt-path not null 1.txt path must end with .txt, 83b8a72a62Sopenharmony_ci if has more than one txt, use comma(,) to separate; 84b8a72a62Sopenharmony_ci 2.txt path also can be directory path. 85b8a72a62Sopenharmony_ci --out-path not null target har binary path, must end with .har. 86b8a72a62Sopenharmony_ci --force default false; if true, force delete destination 87b8a72a62Sopenharmony_ci out file if exists. 88b8a72a62Sopenharmony_ci 89b8a72a62Sopenharmony_ciAPP USAGE: 90b8a72a62Sopenharmony_cijava -jar app_packing_tool.jar --mode <option> --hap-path <option> --out-path <option> 91b8a72a62Sopenharmony_ci--pack-info-path <option> --signature-path [option] --certificate-path [option] --force [option] 92b8a72a62Sopenharmony_ci 93b8a72a62Sopenharmony_ciAPP MODE OPTIONS: 94b8a72a62Sopenharmony_ci --mode not null must be app. 95b8a72a62Sopenharmony_ci --hap-path not null 1.hap path can end with .hap, if has more than one hap, 96b8a72a62Sopenharmony_ci use comma(,) to separate. 97b8a72a62Sopenharmony_ci 2.hap path also can be directory path. 98b8a72a62Sopenharmony_ci --pack-info-path not null pack.info path. 99b8a72a62Sopenharmony_ci --out-path not null target app binary path,must end with .app. 100b8a72a62Sopenharmony_ci --force default false; if true, force delete destination 101b8a72a62Sopenharmony_ci out file if exists. 102b8a72a62Sopenharmony_ci --signature-path signature file path. 103b8a72a62Sopenharmony_ci --certificate-path certificate file path. 104b8a72a62Sopenharmony_ci 105b8a72a62Sopenharmony_ciRETURN VALUE: 106b8a72a62Sopenharmony_ciIn both modes, if package success return 0, fail return 1. 107b8a72a62Sopenharmony_ci 108b8a72a62Sopenharmony_ciEXAMPLES: 109b8a72a62Sopenharmony_cipackage module1.hap 110b8a72a62Sopenharmony_ci java -jar app_packing_tool.jar --mode hap --json-path example/config.json 111b8a72a62Sopenharmony_ci --index-path example/resources.index --maple-so-path example/maple-so 112b8a72a62Sopenharmony_ci --dex-path example/test1.dex,example/test2.dex --shell-apk-path example/test1.apk,example/test2.apk 113b8a72a62Sopenharmony_ci --resources-path example/resources/ --lib-path example/lib/ --out-path example/out/module1.hap --force true 114b8a72a62Sopenharmony_ci 115b8a72a62Sopenharmony_ci example/out/module1.hap 116b8a72a62Sopenharmony_ci | config.json,test1.dex,test2.dex,test1.apk,test2.apk 117b8a72a62Sopenharmony_ci |----libs 118b8a72a62Sopenharmony_ci | | test1.xml 119b8a72a62Sopenharmony_ci | |----lib 120b8a72a62Sopenharmony_ci | | | test2.xml 121b8a72a62Sopenharmony_ci |----assets 122b8a72a62Sopenharmony_ci | |----entry 123b8a72a62Sopenharmony_ci | | | resources.index 124b8a72a62Sopenharmony_ci | | |----resources 125b8a72a62Sopenharmony_ci | | | | test3.xml 126b8a72a62Sopenharmony_ci |----maple 127b8a72a62Sopenharmony_ci | |----arm64 128b8a72a62Sopenharmony_ci | | | test1.so,test2.so 129b8a72a62Sopenharmony_ci 130b8a72a62Sopenharmony_cipackage module2.hap 131b8a72a62Sopenharmony_ci java -jar app_packing_tool.jar --mode hap --json-path example/config.json 132b8a72a62Sopenharmony_ci --out-path example/out/module2.hap --force true 133b8a72a62Sopenharmony_ci 134b8a72a62Sopenharmony_ci example/out/module2.hap 135b8a72a62Sopenharmony_ci | config.json 136b8a72a62Sopenharmony_ci 137b8a72a62Sopenharmony_cipackage demo.app 138b8a72a62Sopenharmony_ci java -jar app_packing_tool.jar --mode app --hap-path example/out/module1.hap,example/out/module2.hap 139b8a72a62Sopenharmony_ci --signature-path example/signature --certificate-path example/certificate 140b8a72a62Sopenharmony_ci --pack-info-path example/pack.info --out-path example/out/demo.app --force true 141b8a72a62Sopenharmony_ci 142b8a72a62Sopenharmony_ci example/out/demo.app 143b8a72a62Sopenharmony_ci | module1.hap 144b8a72a62Sopenharmony_ci | module2.hap 145b8a72a62Sopenharmony_ci | pack.info 146b8a72a62Sopenharmony_ci | signature 147b8a72a62Sopenharmony_ci | certificate 148b8a72a62Sopenharmony_ci 149b8a72a62Sopenharmony_ci 150b8a72a62Sopenharmony_ci----------------------------------------------------------------------------------------------- 151b8a72a62Sopenharmony_ci 152b8a72a62Sopenharmony_ciuse commands for unpackage hap or app. 153b8a72a62Sopenharmony_ci 154b8a72a62Sopenharmony_ciCONSTRANIT: 155b8a72a62Sopenharmony_ci1.When the hap depends on a app, you need to wait the app has been unpackaged, 156b8a72a62Sopenharmony_ci It can be controlled according to the return value of the command execution. 157b8a72a62Sopenharmony_ci2.If the same command appears many times in a command, take the last value that appears. 158b8a72a62Sopenharmony_ci For example: --mode hap --mode app 159b8a72a62Sopenharmony_ci the mode value is app. 160b8a72a62Sopenharmony_ci3.If there are several parameters in the same command, take the first value. 161b8a72a62Sopenharmony_ci For example: --mode hap app 162b8a72a62Sopenharmony_ci the mode value is hap. 163b8a72a62Sopenharmony_ci4.Path cannot start with '--', to avoid conflict with the instruction. 164b8a72a62Sopenharmony_ci5.Command must be lowercase(such as:--mode), and file's suffix is case insensitive. 165b8a72a62Sopenharmony_ci6.Absolute paths is recommended. 166b8a72a62Sopenharmony_ci7.Output path can be specified. The default output path is the path where the app or hap is located. 167b8a72a62Sopenharmony_ci8.After unpackage a hap, json file will be unzipped to the output path. 168b8a72a62Sopenharmony_ci And after unpackage an app, all hap file will be unzipped to the output path. 169b8a72a62Sopenharmony_ci 170b8a72a62Sopenharmony_ciHAP USAGE: 171b8a72a62Sopenharmony_cijava -jar app_unpacking_tool.jar --mode <options> --hap-path <option> 172b8a72a62Sopenharmony_ci--out-path [option] --force [option] --unpackapk [option] 173b8a72a62Sopenharmony_ci 174b8a72a62Sopenharmony_ciHAP MODE OPTIONS: 175b8a72a62Sopenharmony_ci --mode not null must be hap. 176b8a72a62Sopenharmony_ci --hap-path not null hap path. 177b8a72a62Sopenharmony_ci --out-path target hap unpackage path. 178b8a72a62Sopenharmony_ci --force default false; if true, force delete destination 179b8a72a62Sopenharmony_ci out file if exists. 180b8a72a62Sopenharmony_ci --unpack-cut_entry default false; if true, unpack the cut_entry.apk 181b8a72a62Sopenharmony_ci 182b8a72a62Sopenharmony_ciHAR USAGE: 183b8a72a62Sopenharmony_cijava -jar app_unpacking_tool.jar --mode <options> --har-path <option> 184b8a72a62Sopenharmony_ci--out-path [option] --force [option] 185b8a72a62Sopenharmony_ciOPTIONS: 186b8a72a62Sopenharmony_ci --mode not null must be har. 187b8a72a62Sopenharmony_ci --har-path not null har path. 188b8a72a62Sopenharmony_ci --out-path not null target path of unzip. 189b8a72a62Sopenharmony_ci --force default false; if true, force delete destination 190b8a72a62Sopenharmony_ci out file if exists. 191b8a72a62Sopenharmony_ci 192b8a72a62Sopenharmony_ciAPP USAGE: 193b8a72a62Sopenharmony_cijava -jar app_unpacking_tool.jar --mode <options> --app-path <option> 194b8a72a62Sopenharmony_ci--out-path [option] --force [option] --unpackapk [option] 195b8a72a62Sopenharmony_ci 196b8a72a62Sopenharmony_ciAPP MODE OPTIONS: 197b8a72a62Sopenharmony_ci --mode not null must be app. 198b8a72a62Sopenharmony_ci --app-path not null app path. 199b8a72a62Sopenharmony_ci --out-path target app unpackage path. 200b8a72a62Sopenharmony_ci --force default false; if true, force delete destination 201b8a72a62Sopenharmony_ci out file if exists. 202b8a72a62Sopenharmony_ci --unpackapk default false; if true, unpack apk files from hap 203b8a72a62Sopenharmony_ci in the app. 204b8a72a62Sopenharmony_ci 205b8a72a62Sopenharmony_ciRETURN VALUE: 206b8a72a62Sopenharmony_ciIn both modes, if unpackage successfully return 0, fail return 1. 207b8a72a62Sopenharmony_ci 208b8a72a62Sopenharmony_ciEXAMPLES: 209b8a72a62Sopenharmony_ciunpackage demo.app 210b8a72a62Sopenharmony_ci java -jar app_unpacking_tool.jar --mode app --app-path example/demo.app 211b8a72a62Sopenharmony_ci --out-path example/out/ --force true 212b8a72a62Sopenharmony_ci 213b8a72a62Sopenharmony_ciunpackage test1.hap 214b8a72a62Sopenharmony_ci java -jar app_unpacking_tool.jar --mode hap --hap-path example/out/module1.hap 215b8a72a62Sopenharmony_ci --out-path example/out/TEST --force true 216b8a72a62Sopenharmony_ci 217b8a72a62Sopenharmony_ciunpackage test2.hap 218b8a72a62Sopenharmony_ci java -jar app_unpacking_tool.jar --mode hap --hap-path example/out/module2.hap --force true 219b8a72a62Sopenharmony_ci 220b8a72a62Sopenharmony_ci example/out 221b8a72a62Sopenharmony_ci | module1.hap 222b8a72a62Sopenharmony_ci | module2.hap 223b8a72a62Sopenharmony_ci |----TEST 224b8a72a62Sopenharmony_ci | | config.json 225b8a72a62Sopenharmony_ci |----module2 226b8a72a62Sopenharmony_ci | | config.json 227