解决国内环境或者企业内网环境问题,往往访问Maven仓库比较困难,此时可以设置Gradle仓库镜像。
1) 在用户目录新建一个 .gradle 文件夹,比如我的机器登录账户是 lwx48xxxx, 那么具体路径为 C:\Users\lwx48xxxx\.gradle;
2) 在这个目录下新建一个 init.gradle 文件放入以下内容
allprojects { buildscript { repositories { mavenLocal() maven { url 'http://mirrors.tools.huawei.com/maven/' } maven { // 内网JetBrains仓库,下载依赖的IDE和jdk等,用于编译和运行插件 url 'http://artifactory.cde.huawei.com/artifactory/jetbrains-public/' } maven {url "http://artifactory.cde.huawei.com/artifactory/gradle-plugins/"} maven {url "http://artifactory.cde.huawei.com/artifactory/maven-public/"} maven {url "http://artifactory.cde.huawei.com/artifactory/huawei-gradlebuild/"} } dependencies { // gradle-intellij-plugin用于构建JetBrains插件 // 请确保始终升级到最新版本 // http://artifactory.cde.huawei.com/artifactory/maven-public/org/jetbrains/intellij/org.jetbrains.intellij.gradle.plugin/ // classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin" } } repositories { mavenLocal() maven { url 'http://mirrors.tools.huawei.com/maven/' } maven { // 内网JetBrains仓库,下载依赖的IDE和jdk等,用于编译和运行插件 url 'http://artifactory.cde.huawei.com/artifactory/jetbrains-public/' } maven {url "http://artifactory.cde.huawei.com/artifactory/gradle-plugins/"} maven {url "http://artifactory.cde.huawei.com/artifactory/maven-public/"} maven {url "http://artifactory.cde.huawei.com/artifactory/huawei-gradlebuild/"} } } settingsEvaluated { settings -> settings.pluginManagement { plugins { } resolutionStrategy { } repositories { maven {url "http://artifactory.cde.huawei.com/artifactory/gradle-plugins/"} } } }复制
本系列归档至《跟老卫学HarmonyOS开发》:https://github.com/waylau/harmonyos-tutorial
参考书籍《鸿蒙HarmonyOS应用开发从入门到精通》 :https://item.jd.com/13696724.html