switch-gradle-mirror.bat 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. @echo off
  2. echo ========================================
  3. echo 切换 Gradle 镜像源
  4. echo ========================================
  5. echo.
  6. echo 请选择镜像源:
  7. echo 1. 腾讯云镜像(推荐)
  8. echo 2. 阿里云镜像
  9. echo 3. 官方源(默认)
  10. echo.
  11. set /p choice=请输入选项 (1-3):
  12. set "gradleProps=android\gradle\wrapper\gradle-wrapper.properties"
  13. if "%choice%"=="1" (
  14. echo.
  15. echo 切换到腾讯云镜像...
  16. powershell -Command "(Get-Content '%gradleProps%') -replace 'distributionUrl=https\\://services.gradle.org/distributions/gradle-8.11.1-all.zip', 'distributionUrl=https\\://mirrors.cloud.tencent.com/gradle/gradle-8.11.1-all.zip' | Set-Content '%gradleProps%'"
  17. echo 已切换到腾讯云镜像!
  18. ) else if "%choice%"=="2" (
  19. echo.
  20. echo 切换到阿里云镜像...
  21. powershell -Command "(Get-Content '%gradleProps%') -replace 'distributionUrl=https\\://services.gradle.org/distributions/gradle-8.11.1-all.zip', 'distributionUrl=https\\://mirrors.aliyun.com/gradle/gradle-8.11.1-all.zip' | Set-Content '%gradleProps%'"
  22. echo 已切换到阿里云镜像!
  23. ) else if "%choice%"=="3" (
  24. echo.
  25. echo 切换到官方源...
  26. powershell -Command "(Get-Content '%gradleProps%') -replace 'distributionUrl=https\\://mirrors.*gradle-8.11.1-all.zip', 'distributionUrl=https\\://services.gradle.org/distributions/gradle-8.11.1-all.zip' | Set-Content '%gradleProps%'"
  27. echo 已切换到官方源!
  28. ) else (
  29. echo 无效选项!
  30. pause
  31. exit /b 1
  32. )
  33. echo.
  34. echo 当前配置:
  35. type "%gradleProps%" | findstr distributionUrl
  36. echo.
  37. pause