maven仓库中的LastUpdated文件删除脚本

发布时间 2023-03-29 09:14:09作者: 红尘沙漏

cleanLastUpdated.bat(windows版本)

@echo off
rem create by NettQun  
 
rem 这里写你的仓库路径
set REPOSITORY_PATH=D:\Java\maven-repository\maven-aliyun\repository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    del /s /q %%i
)
rem 搜索完毕
pause

  

cleanLastUpdated.sh(linux版本)

# create by NettQun  
 
# 这里写你的仓库路径
REPOSITORY_PATH=~/Documents/tools/repository
echo 正在搜索...
find $REPOSITORY_PATH -name "*lastUpdated*" | xargs rm -fr
echo 搜索完

  

清理maven库的 xxx.jar.lastUpdated 文件bat脚本

clean-all_maven-repos.bat

@echo off

set REPOSITORY_PATH=%1

if "%REPOSITORY_PATH%" == "" (
    echo "Usage: %0 <maven_repository_path>"
    echo "Example: %0 D:\\OneMvnRepository"
    echo "Explain: "~" is your profile's home directory" 
    echo. 
    echo. 
    echo "press enter to quit!" & pause > nul 
    goto :eof
)

echo. 
echo "Began clean lastUpdated file"
echo. 

for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
   del /s /q %%i
)

for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*sha1*"') do (
   del /s /q %%i
)

for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*repositories*"') do (
   del /s /q %%i
)

echo. 
echo "End clean lastUpdated file."
echo. 
echo. 
echo "press enter to exit!" & pause > nul 

exit