maven {
url 'https://xxx.com'
content {
includeGroupByRegex 'com.company.*'
}
}
includeGroup
includeModule
includeVersion
excludeGroup
...
参考:https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/repositories/RepositoryContentDescriptor.html
有时候,有且仅有指定仓库,才包含 库。这样指定lib,只需要到指定的maven中拉取。
不需要再去逐个获取失败,知道获取成功的方式。
repositories {
// This repository will _not_ be searched for artifacts in my.company
// despite being declared first
mavenCentral()
exclusiveContent {
forRepository {
maven {
url "https://repo.mycompany.com/maven2"
}
}
filter {
// this repository *only* contains artifacts with group "my.company"
includeGroup "my.company"
}
}
}
这个代码表明,有且仅有这个仓库才包含 my.company group 的lib,遇到 my.company 就直接拉取这个仓库。
参考:https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/repositories/InclusiveRepositoryContentDescriptor.html
repositories {
maven {
url "https://repo.mycompany.com/releases"
mavenContent {
releasesOnly()
}
}
maven {
url "https://repo.mycompany.com/snapshots"
mavenContent {
snapshotsOnly()
}
}
}
Android现在默认使用 google、mavenCentral 两个,由于各种原因访问速度或不通。
使用阿里替代
repositories {
//gradlePluginPortal()
//google()
//mavenCentral()
maven { url 'https://maven.aliyun.com/repository/google' }
//central和jcenter的聚合仓库
maven { url 'https://maven.aliyun.com/repository/public' }
//仅顶级build.gradle需配置插件仓库
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
阿里云云效Maven: https://developer.aliyun.com/mvn/guide
https://docs.gradle.org/current/userguide/declaring_repositories.html