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 ...
随机推荐
- HDU 5782 Cycle —— KMP
题目:Cycle 链接:http://acm.hdu.edu.cn/showproblem.php?pid=5782 题意:给出两个字符串,判断两个字符串的每一个前缀是否循环相等(比如abc 和 ca ...
- Baby-Step-Giant-Step 很酷的算法
Baby-Step-Giant-Step BSGS算法用于解决形如: A ^ x ≡ B ( mod C ) 的问题. 学这个算法前需要具备以下知识:快速幂取模.扩展欧几里 ...
- AssemblyScript的测试
详细文档介绍 export function f(x: i32): i32 { if (x === 1 || x === 2) { return 1; } return f(x - 1) + f(x ...
- hadoop分布式系统架构详解
hadoop 简单来说就是用 java写的分布式 ,处理大数据的框架,主要思想是 “分组合并” 思想. 分组:比如 有一个大型数据,那么他就会将这个数据按照算法分成多份,每份存储在 从属主机上,并且在 ...
- Visual Studio 2017调试开源项目代码
在我们的开发过程中很多时候我们会从GitHub上面下载一些开源的项目代码,然后在此基础上进行调试,正常情况下我们只需要将项目的源代码编译成Dll或者在.Net Core项目中直接引用相应的Nuget包 ...
- mysql对身份证号码进行脱敏处理
select * from test 格式:INSERT(str,pos,len,newstr) 解释: str:查询的例 pos:起始位置 len:从起始位置开始被后面newstr替换的长度 new ...
- 转 Pycharm及python安装详细教程
转 : http://blog.csdn.net/qq_29883591/article/details/52664478 首先我们来安装Python 1.首先进入网站下载:点击打开链接(或自己输入网 ...
- C-Lodop提示“有窗口已打开,先关闭它(持续如此请刷新页面)!”
c-lodop显示“有窗口已打开,先关闭它(持续如此时请刷新页面)!”如果连续执行多个预览语句等导致的,可以预先判断一下,并可以自定义修改窗口已打开的提示,该默认提示的位置如本博客的下图http:// ...
- Spring Boot 构建电商基础秒杀项目 (十二) 总结 (完结)
SpringBoot构建电商基础秒杀项目 学习笔记 系统架构 存在问题 如何发现容量问题 如何使得系统水平扩展 查询效率低下 活动开始前页面被疯狂刷新 库存行锁问题 下单操作步骤多,缓慢 浪涌流量如何 ...
- BZOJ4003[JLOI2015]城池攻占——可并堆
题目描述 小铭铭最近获得了一副新的桌游,游戏中需要用 m 个骑士攻占 n 个城池. 这 n 个城池用 1 到 n 的整数表示.除 1 号城池外,城池 i 会受到另一座城池 fi 的管辖, 其中 fi ...