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 ...
随机推荐
- [翻译]在asp.net core2.0 OpenID Connect Handler中丢失了声明(CLaims)?
注:这是一篇翻译,来自这里.这篇文章讲述了在asp.net core2.0中使用openid connect handler的过程中解析不到你想要的claim时,你可以参考这篇文章. Missing ...
- 对B+树,B树,红黑树的理解
出处:https://www.jianshu.com/p/86a1fd2d7406 写在前面,好像不同的教材对b树,b-树的定义不一样.我就不纠结这个到底是叫b-树还是b-树了. 如图所示,区别有以下 ...
- zTree树形菜单使用实例
在每个节点添加 id 和 pid, id 表示当前节点编号,pid 表示父节点编号 第一步:在页面显示菜单位置,添加 ul设置 class=”ztree” 第二步:开启简单数据格式支持 第三步:编写树 ...
- 缓存session,cookie,sessionStorage,localStorage的区别
https://www.cnblogs.com/cencenyue/p/7604651.html(copy) 浅谈session,cookie,sessionStorage,localStorage的 ...
- ReCAPTCHA & 手势验证
手势验证 recaptcha https://www.vaptcha.com/ https://www.vaptcha.com/document https://www.iviewui.com/com ...
- 另一个ado工具类
using System;using System.Collections.Generic;using System.Text;using System.Data.SqlClient;using Sy ...
- How to proof Pi
可以把圆想象成一个无限增大角的正多边形,通过倍角公式即勾股定理进行迭代. sin2x=2sinxcosx
- DeepLearning训练方法
1.BN层训练技巧 缩小输入尺寸,这样可以提高batchsize的大小,在BN层适应了该数据集后,固定住BN层参数,放大输入尺寸继续训练 2.语义分割中解决网络输出尺寸与原尺寸的gap方法(如 1/8 ...
- hdu-4738(tarjan割边)
题意:给你n个点,m条边,边有权值,问你最小的花费使图不连通: 解题思路:就是求边权最小的割边,但这道题有坑点: 1.有重边(桥的两个点有重边时,你去掉一条边并没什么d用): 2.当权值为0的时候,我 ...
- Lisp小程序,大作用,不该放弃!
从听说autolisp到现在已经20年了, 学了一点点, 可惜中间没能坚持下来, 放弃了! 今天在画图, 图纸是从revit转成dwg的, 其中有些文本的朝向是错误的, 如果手工旋转很是费事, ...