gradle项目中怎么集中管理你的依赖库

项目结构

引用
root

--gradleScript

----dependencies.gradle

--module1

----build.gradle

--build.gradle

IngradleScript/dependecies.gradle:

引用
ext {

//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:

引用
// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

相关推荐