1 Star 0 Fork 260

chthollystar/developtools_packing_tool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
packingTool.sh 3.17 KB
一键复制 编辑 原始数据 按行查看 历史
zhrenqiang 提交于 2024-04-19 20:44 . sh: set -exu -o pipefail
#!/usr/bin/env bash
# Copyright (c) 2022-2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eux
set -o pipefail
root_path=$1
pack_build_out_jar_path=$2
pack_build_out_path=$3
toolchain=$4
compile_java=$5
fastjson_jar=$6
compress_jar=$7
final_path=$(pwd)
jar_dir="jar"
pack_jar_file="app_packing_tool.jar"
fastjson_jar_file="fastjson-1.2.83.jar"
compress_jar_file="commons-compress-1.24.0.jar"
jar_directory="${root_path}/jar"
pack_jar_path="${root_path}/${jar_dir}/${pack_jar_file}"
manifest_path="${root_path}/META-INF/packing_tool/MANIFEST.MF"
out_dir="${root_path}/out/${toolchain}/packing_tool"
if [ -d "${out_dir}/ohos" ]
then
echo "${out_dir}/ohos exist"
else
mkdir -p "${out_dir}/ohos"
fi
compile_command="javac -source 1.8 -target 1.8 -cp ${fastjson_jar}:${compress_jar} -d ${out_dir} ${compile_java}"
eval ${compile_command}
temp_dir="$root_path/jar/packing_temp_${toolchain}"
if [ -d "${temp_dir}" ]
then
echo "${temp_dir} exit"
else
mkdir ${temp_dir}
fi
cd ${out_dir}
product_pack_jar_command="jar -cvfm ${temp_dir}/${pack_jar_file} ${manifest_path} ./ohos"
eval ${product_pack_jar_command}
# merge app_packing_tool.jar and fastjson/commons-compress
cp ${fastjson_jar} "${temp_dir}/${fastjson_jar_file}"
cp ${compress_jar} "${temp_dir}/${compress_jar_file}"
detach_pack_jar_command="jar -xvf ${pack_jar_file}"
detach_fastjson_jar_command="jar -xvf ${fastjson_jar_file}"
detach_compress_jar_command="jar -xvf ${compress_jar_file}"
cd ${temp_dir}
eval ${detach_pack_jar_command}
eval ${detach_fastjson_jar_command}
eval ${detach_compress_jar_command}
cp "$root_path/jar/NOTICE" "META-INF/NOTICE.txt"
rm ${pack_jar_file}
rm ${fastjson_jar_file}
rm ${compress_jar_file}
cd ${jar_directory}
temp_pack_jar_dir="${root_path}/jar/packtool_${toolchain}"
temp_pack_jar_path="${root_path}/jar/packtool_${toolchain}/${pack_jar_file}"
merge_pack_fast_jar_command="jar -cvfm ${temp_pack_jar_path} ${manifest_path} -C ${temp_dir} ."
if [ -d "${temp_pack_jar_dir}" ]
then
echo "${temp_pack_jar_dir} exist"
else
mkdir -p ${temp_pack_jar_dir}
fi
eval ${merge_pack_fast_jar_command}
# make out dir
final_pack_out_path="${final_path}/${pack_build_out_path}"
final_pack_jar_path="${final_path}/${pack_build_out_jar_path}"
if [ -d "$final_pack_out_path" ]
then
echo "${final_pack_out_path} exist"
else
mkdir -p ${final_pack_out_path}
fi
copy_command="cp ${temp_pack_jar_path} ${final_pack_jar_path}"
eval ${copy_command}
if [ -f "${pack_jar_file}"]
then
echo "${pack_jar_file} exist"
else
cp ${temp_pack_jar_path} ${pack_jar_file}
fi
rm -rf ${temp_pack_jar_dir}
rm -rf ${temp_dir}
rm -rf ${out_dir}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chthorystar/developtools_packing_tool.git
git@gitee.com:chthorystar/developtools_packing_tool.git
chthorystar
developtools_packing_tool
developtools_packing_tool
master

搜索帮助