gradle配置统一管理
配置全局参数
根目录build.gradle文件:
主要关注ext部分
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.61'
repositories {
google()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
//base version
compileSdkVersion = 28
buildToolsVersion = "28.0.2"
minSdkVersion = 19
targetSdkVersion = 26
versionCode = gitVersionCode()
versionName = gitVersionTag()
leanback = "com.android.support:leanback-v17:27.1.1"
annotation = "com.android.support:support-annotations:27.1.1"
v13 = "com.android.support:support-v13:27.1.1"
//kotlin
kotlinStdlibJDK7 = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// arch
lifecycle = "android.arch.lifecycle:extensions:1.1.1"
// exoplayer
exoplayer_version = "2.8.4"
exoplayer = "com.google.android.exoplayer:exoplayer:$exoplayer_version"
exoplayer_core = "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
exoplayer_hls = "com.google.android.exoplayer:exoplayer-hls:$exoplayer_version"
exoplayer_ui = "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"
multidex = "com.android.support:multidex:1.0.3"
file_chooser = "com.obsez.android.lib.filechooser:filechooser:1.1.10"
//okhttp3
okhttp3 = "com.squareup.okhttp3:okhttp:3.11.0"
loggingInterceptor = "com.squareup.okhttp3:logging-interceptor:3.11.0"
//retrofit
retrofit = "com.squareup.retrofit2:retrofit:2.4.0"
gsonConvert = "com.squareup.retrofit2:converter-gson:2.4.0"
glide = "com.github.bumptech.glide:glide:3.7.0"
logger = "com.orhanobut:logger:2.2.0"
permission = "com.github.hotchemi:permissionsdispatcher:3.2.0"
permission_processor = "com.github.hotchemi:permissionsdispatcher-processor:3.2.0"
fhttpserver = "cn.hotapk:fhttpserver:0.2.0"
rxbus = "com.blankj:rxbus:1.5"
libaums = "com.github.mjdev:libaums:0.5.5"
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
def gitVersionCode() {
def cmd = 'git rev-list HEAD --first-parent --count'
cmd.execute().text.trim().toInteger()
}
def gitVersionTag() {
def cmd = 'git describe --tags --long --always --dirty=-dev'
def version = cmd.execute().text.trim()
return version
}
在项目的build.gradle里面使用:
如下 rootProject.ext+你要引入的配置参数
configurations.all {
resolutionStrategy.force rootProject.ext.okhttp3
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.kotlinStdlibJDK7
implementation rootProject.ext.leanback
implementation rootProject.ext.lifecycle
implementation rootProject.ext.exoplayer
implementation rootProject.ext.exoplayer_core
implementation rootProject.ext.exoplayer_hls
implementation rootProject.ext.exoplayer_ui
implementation rootProject.ext.multidex
implementation rootProject.ext.file_chooser
implementation rootProject.ext.retrofit
implementation rootProject.ext.gsonConvert
implementation rootProject.ext.loggingInterceptor
implementation rootProject.ext.glide
implementation rootProject.ext.logger
implementation rootProject.ext.permission
implementation rootProject.ext.v13
implementation rootProject.ext.fhttpserver
implementation rootProject.ext.rxbus
implementation rootProject.ext.libaums
annotationProcessor rootProject.ext.permission_processor
testImplementation 'junit:junit:4.12'
}
gradle配置统一管理的更多相关文章
- Android Studio配置统一管理依赖版本号引用
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 本Demo采用的是其中一个方案,其他方案请阅读参考资料<Android Studio中统一管理版本号引用配置> 使用步骤 ...
- python项目实现配置统一管理的方法
一个比较大的项目总是会涉及到很多的参数,最好的方法就是在一个地方统一管理这些参数.最近看了不少的python项目,总结了两种很有意思的配置管理方法. 第一种 基于easydict实现的配置管理 首先需 ...
- 多个SpringMVC项目配置统一管理(来自于springCloud的统一配置思路)
因公司项目分多个系统进行开发,而系统架构几乎完全一样,所以同样的配置文件会存在不同的系统中 当其中的某些配置需要修改时,就需要依次把所有系统中相关的配置都修改掉 纯耗时且没技术含量的体力活 所以借鉴S ...
- SpringCloud-微服务配置统一管理SpringCloud Config(七)
前言:对于应用,配制文件通常是放在项目中管理的,它可能有spring.mybatis.log等等各种各样的配置文件和属性文件,另外你还可能有开发环境.测试环境.生产环境等,这样的话就得一式三份,若是传 ...
- SpringCloud微服务(06):Config组件,实现配置统一管理
本文源码:GitHub·点这里 || GitEE·点这里 一.Config简介 在微服务系统中,服务较多,相同的配置:如数据库信息.缓存.参数等,会出现在不同的服务上,如果一个配置发生变化,需要修改很 ...
- Android Studio 使用笔记:在图形界面使用 Gradle 配置项目所需jar包
在 Android Studio 中使用第三方 jar 包,可以直接下载后添加到项目中,也可以使用 Gradle 配置进行管理.图形界面下十分简单. 点击下图中间的图标,或者选中 Model ,按F4 ...
- Android 统一配置依赖管理
Android Studio中默认就是使用Gradle来构建管理工程的,当我们在工程构建过程中创建了多个Module时,就可能存在一个问题,那就是每个Module以及Module中一些公用库的依赖存在 ...
- GRADLE依赖的统一管理
参考链接:http://stormzhang.com/android/2016/03/13/gradle-config/ 我想大部分人应该都在使用Gradle来依赖管理,还没有使用的去面壁思过,Gra ...
- 如何在 ETL 项目中统一管理上百个 SSIS 包的日志和包配置框架
一直准备写这么一篇有关 SSIS 日志系统的文章,但是发现很难一次写的很完整.因为这篇文章的内容可扩展的性太强,每多扩展一部分就意味着需要更多代码,示例和理论支撑.因此,我选择我觉得比较通用的 LOG ...
随机推荐
- Mac上通过iterm 上传文件到服务器
.安装 brew install lrzsz #这里以homebrew方式安装12.脚本 拉取 https://github.com/mmastrac/iterm2-zmodem 两个sh文件,将他们 ...
- [转帖]十分钟快速理解DPI和PPI,不再傻傻分不清!
十分钟快速理解DPI和PPI,不再傻傻分不清! https://baijiahao.baidu.com/s?id=1605834796518990333&wfr=spider&for= ...
- Failed to bind properties under 'spring.datasource' to javax.sql.DataSource
这是我的配置文件 # 国际化配置文件(包名.基础名) spring.messages.basename=i18n.login server.tomcat.uri-encoding=UTF- sprin ...
- 如何使用apache自带的ab压力测试工具
ab是apache自带的一个很好用的压力测试工具,当安装完apache的时候,就可以在bin下面找到ab 1 我们可以模拟100个并发用户,对一个页面发送1000个请求 ./ab -n1000 -c1 ...
- git format-patch制作内核补丁
git init git add ./ git commit 之后修改代码 修改代码后执行 git add ./ git commit 执行完成后执行git log查询commit 的id 执行git ...
- 工厂类,配置文件,静态方法,反射构成编译器解耦;ioc的一个概念 ;通过xml创建容器里面存储对象
工厂类,配置文件,静态,反射方法构成编译器解耦;ioc的一个概念
- xx.hbm.xml中相关重要的配置
1.<!-- 指定hibernate操作数据库时的隔离级别 #hibernate.connection.isolation 1|2|4|8 ...
- h.264并行熵解码
在前面讨论并行解码的章节中,我们专注于讨论解码的宏块重建部分,甚至把宏块重建描述成宏块解码,这是因为在解码工作中,宏块重建确实占了相当大的比重,不过解码还包含其它的部分,按照解码流程可粗略分为: 读取 ...
- Nginx IP地址透传
L:119
- 简单介绍一下在CentOS上安装Docker。
简单介绍一下在CentOS上安装Docker. 前置条件: 64-bit 系统 kernel 3.10+ 1.检查内核版本,返回的值大于3.10即可. $ uname -r 2.使用 sudo 或 r ...