gradle项目中怎么集中管理你的依赖库
项目结构
--gradleScript
----dependencies.gradle
--module1
----build.gradle
--build.gradle
IngradleScript/dependecies.gradle:
//Version
supportLibrary='22.2.1'
//SupportLibrariesdependencies
supportDependencies=[
design:"com.android.support:design:${supportLibrary}",
recyclerView:"com.android.support:recyclerview-v7:${supportLibrary}",
cardView:"com.android.support:cardview-v7:${supportLibrary}",
appCompat:"com.android.support:appcompat-v7:${supportLibrary}",
supportAnnotation:"com.android.support:support-annotations:${supportLibrary}",
]
}
Inthetoplevelfilebuild.gradle:
buildscript{
repositories{
jcenter()
}
dependencies{
classpath'com.android.tools.build:gradle:1.2.3'
}
}
//Loaddependencies
applyfrom:'gradleScript/dependencies.gradle'
Inthemodule1/build.gradle:
//Modulebuildfile
dependencies{
//......
compilesupportDependencies.appCompat
compilesupportDependencies.design
}
Reference:http://gmariotti.blogspot.com/2015/07/how-to-centralize-support-libraries.html