我希望我在repositories
块中指定的buildscript.repositories
与依赖项repositories
块的相同存储库相同。请看我的例子:
buidldscript
:buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:2.1.2"
}
}
repositories {
jcenter()
}
我该如何做以下事情?
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:2.1.2"
}
}
repositories = buildscript.repositories
答案 0 :(得分:3)
根据这个question and answer,你只需先在变量中声明它:
buildscript {
ext.myRepos = {
maven { url "https://plugins.gradle.org/m2/" }
}
repositories myRepos
dependencies {
classpath "com.android.tools.build:gradle:2.1.2"
}
}
repositories myRepos
理想情况下,我想使用plugins { }
块,但Android gradle插件不在plugins.gradle.org上。
或
buildscript {
configure([buildscript.repositories, project.repositories]) {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.android.tools.build:gradle:2.1.2"
}
}