shell
#!/bin/bash
# 把 .gradle/caches/modules-2/files-2.1 整理成目录仓库模式
# author:Jin
# date:20210915
# 使用方法:放到 files-2.1 目录运行
#cd ..;
MyDir=jin_maven/
rm -rf jin_maven* 2>&1 >/dev/null
mkdir -p $MyDir;
ls -R * | grep -v '.*/$'| grep -v jin_maven |egrep -B1 '.jar|.pom|.aar'|grep -v "\-\-"|tee jinJar.txt;
echo;sleep 1
echo '################## START ####################'
echo;sleep 2
while read line
do
endFlag=`echo $line|grep '.*:$'`
if [ -n "$endFlag" ]; then
sourceDir=`echo $endFlag | awk -F ':' '{print $1}'`
#echo $sourceDir
destDirTmp=`dirname $line`":"
dprefix=`echo $destDirTmp| awk -F '/' '{print $1}'|sed 's#\.#/#g'`
dendfix=`echo $destDirTmp| awk -F '/' '{print $2"/"$3"/"$4"/"$5"/"$6"/"$7"/"$8"/"$9}'`
#echo "destDirTmp -- " $destDirTmp
#echo "dprefix -- "$dprefix
#echo "dendfix -- "$dendfix
destDir=$MyDir$dprefix/`echo $dendfix | awk -F ':' '{print $1}'`
else
#echo "原 路 径 -- "$sourceDir/$line
#echo "目标路径 -- "$destDir/$line
if [ ! -d "$destDir" ]; then
echo "directory is not exists; mkdir $destDir"
mkdir -p $destDir
echo "cp -rp $sourceDir/$line $destDir/$line"
cp -rp $sourceDir/$line $destDir/$line;
else
echo "cp -rp $sourceDir/$line $destDir/$line"
cp -rp $sourceDir/$line $destDir/$line;
fi;
fi;
done < jinJar.txt;
echo
echo "############# FINISH #############"
rm -rf jinJar.txt
转换后,压缩为 zip, 直接导入到 jfrog 中