1 Star 0 Fork 261

孙旭辉/developtools_packing_tool_liqing2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
packingTool.sh 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
zhrenqiang 提交于 2024-07-30 19:10 . upgrade commons jar version
#!/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
io_jar=$8
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.26.1.jar"
io_jar_file="commons-io-2.15.1.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}:${io_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}"
cp ${io_jar} "${temp_dir}/${io_jar_file}"
detach_pack_jar_command="jar -xvf ${pack_jar_file}"
detach_fastjson_jar_command="jar -xvf ${fastjson_jar_file}"
detach_io_jar_command="jar -xvf ${io_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_io_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}
rm ${io_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/sun-xuhui-1/developtools_packing_tool_liqing2.git
git@gitee.com:sun-xuhui-1/developtools_packing_tool_liqing2.git
sun-xuhui-1
developtools_packing_tool_liqing2
developtools_packing_tool_liqing2
master

搜索帮助