本地构建spotbugs,替换gradle的默认仓库地址。
1 配置gradle的init.gradle文件
spotbugs使用gradle wrapper构建,所以构建时会去下载gradle。下载地址配置在文件spotbugs/gradle/gradle-wrapper.properties中
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
如果构建时下载gradle失败,可以修改distributionUrl的值。
distributionUrl=https\://mirrors.tencent.com/gradle/gradle-8.5-bin.zip
或者
distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-8.5-bin.zip
gradle下载完成后,设置全局的插件仓库。找到gradle所在的目录,在init.d目录下配置。
C:\Users\xxx\.gradle\wrapper\dists\gradle-8.5-bin\5t9huq95ubn472n8rpzujfbqh\gradle-8.5\init.d
在init.d目录下新建init.gradle文件,内容:
settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
// 新增的插件库地址
maven {
url "https://maven.aliyun.com/repository/gradle-plugin/"
}
// 保留默认的插件库地址
gradlePluginPortal()
mavenCentral()
google()
}
}
settings.dependencyResolutionManagement {
repositories {
mavenLocal() // 本地 Maven 仓库
// 定义全局依赖库仓库
maven { url = uri("https://maven.aliyun.com/repository/public") } // 阿里云的 Maven 仓库
mavenCentral() // Maven Central 仓库
}
}
}
2 配置/spotbugs/settings.gradle.kts文件
文件开头增加内容:
pluginManagement {
repositories {
maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin/") }
// 保留默认的插件库地址
gradlePluginPortal()
mavenCentral()
google()
}
}
文件结尾增加内容:
dependencyResolutionManagement {
repositories {
mavenLocal()
maven { url = uri("https://maven.aliyun.com/repository/public") }
mavenCentral()
}
}
3 修改/spotbugs/build.gradle文件
修改原来的repositories配置。
原始:
allprojects {
repositories {
mavenCentral()
}
dependencies {
def junitVersion = '5.10.1'
compileOnly platform("org.junit:junit-bom:$junitVersion")
testImplementation platform("org.junit:junit-bom:$junitVersion")
}
}
修改后:
allprojects {
repositories {
mavenLocal()
maven {
url "https://maven.aliyun.com/repository/public"
}
mavenCentral()
}
dependencies {
def junitVersion = '5.10.1'
compileOnly platform("org.junit:junit-bom:$junitVersion")
testImplementation platform("org.junit:junit-bom:$junitVersion")
}
}
4 修改/spotbugs/buildSrc/build.gradle.kts文件
修改该文件的repositories配置
改前:
repositories {
gradlePluginPortal()
}
改后:
repositories {
mavenLocal()
maven { url = uri("https://maven.aliyun.com/repository/public") }
mavenCentral()
gradlePluginPortal()
}
5 修改/spotbugs/spotbugs-tests/build.gradle文件
在dependencies配置前增加配置
repositories {
mavenLocal()
maven {
url = uri("https://maven.aliyun.com/repository/public")
}
mavenCentral()
}
6 修改/spotbugs/spotbugsTestCases/build.gradle文件
在dependencies配置前增加配置
repositories {
mavenLocal()
maven {
url = uri("https://maven.aliyun.com/repository/public")
}
mavenCentral()
}
阿里maven仓地址信息
仓库名称 | 阿里云仓库地址 | 阿里云仓库地址(老版) | 源地址 |
---|---|---|---|
central | https://maven.aliyun.com/repository/central | https://maven.aliyun.com/nexus/content/repositories/central | https://repo1.maven.org/maven2/ |
public | https://maven.aliyun.com/repository/public | https://maven.aliyun.com/nexus/content/groups/public | central仓和jcenter仓的聚合仓 |
gradle-plugin | https://maven.aliyun.com/repository/gradle-plugin | https://maven.aliyun.com/nexus/content/repositories/gradle-plugin | https://plugins.gradle.org/m2/ |
apache snapshots | https://maven.aliyun.com/repository/apache-snapshots | https://maven.aliyun.com/nexus/content/repositories/apache-snapshots | https://repository.apache.org/snapshots/ |