配置全局参数

根目录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配置统一管理的更多相关文章

  1. Android Studio配置统一管理依赖版本号引用

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 本Demo采用的是其中一个方案,其他方案请阅读参考资料<Android Studio中统一管理版本号引用配置> 使用步骤 ...

  2. python项目实现配置统一管理的方法

    一个比较大的项目总是会涉及到很多的参数,最好的方法就是在一个地方统一管理这些参数.最近看了不少的python项目,总结了两种很有意思的配置管理方法. 第一种 基于easydict实现的配置管理 首先需 ...

  3. 多个SpringMVC项目配置统一管理(来自于springCloud的统一配置思路)

    因公司项目分多个系统进行开发,而系统架构几乎完全一样,所以同样的配置文件会存在不同的系统中 当其中的某些配置需要修改时,就需要依次把所有系统中相关的配置都修改掉 纯耗时且没技术含量的体力活 所以借鉴S ...

  4. SpringCloud-微服务配置统一管理SpringCloud Config(七)

    前言:对于应用,配制文件通常是放在项目中管理的,它可能有spring.mybatis.log等等各种各样的配置文件和属性文件,另外你还可能有开发环境.测试环境.生产环境等,这样的话就得一式三份,若是传 ...

  5. SpringCloud微服务(06):Config组件,实现配置统一管理

    本文源码:GitHub·点这里 || GitEE·点这里 一.Config简介 在微服务系统中,服务较多,相同的配置:如数据库信息.缓存.参数等,会出现在不同的服务上,如果一个配置发生变化,需要修改很 ...

  6. Android Studio 使用笔记:在图形界面使用 Gradle 配置项目所需jar包

    在 Android Studio 中使用第三方 jar 包,可以直接下载后添加到项目中,也可以使用 Gradle 配置进行管理.图形界面下十分简单. 点击下图中间的图标,或者选中 Model ,按F4 ...

  7. Android 统一配置依赖管理

    Android Studio中默认就是使用Gradle来构建管理工程的,当我们在工程构建过程中创建了多个Module时,就可能存在一个问题,那就是每个Module以及Module中一些公用库的依赖存在 ...

  8. GRADLE依赖的统一管理

    参考链接:http://stormzhang.com/android/2016/03/13/gradle-config/ 我想大部分人应该都在使用Gradle来依赖管理,还没有使用的去面壁思过,Gra ...

  9. 如何在 ETL 项目中统一管理上百个 SSIS 包的日志和包配置框架

    一直准备写这么一篇有关 SSIS 日志系统的文章,但是发现很难一次写的很完整.因为这篇文章的内容可扩展的性太强,每多扩展一部分就意味着需要更多代码,示例和理论支撑.因此,我选择我觉得比较通用的 LOG ...

随机推荐

  1. 05 Hadoop 设置块的大小

    1.是在hdfs的配置文件中配置 2.是在app程序中设置 注意:假设配置文件的最大是   20K   最小是 10K   文件大小为72  块数就是 4 在程序中设置最大为15K    切割块数  ...

  2. [转帖]利用hydra(九头蛇)暴力破解内网windows登录密码

    利用hydra(九头蛇)暴力破解内网windows登录密码 https://blog.csdn.net/weixin_37361758/article/details/77939070 尝试了下 能够 ...

  3. hive聚合函数和表生成函数

    explode生成单独的一行

  4. Java中 VO、 PO、DO、DTO、 BO、 QO、DAO、POJO的概念(转)

    PO(persistant object) 持久对象 在 o/r 映射的时候出现的概念,如果没有 o/r 映射,没有这个概念存在了.通常对应数据模型 ( 数据库 ), 本身还有部分业务逻辑的处理.可以 ...

  5. 初识GetMapping(""),使用方法

    GetMapping("value = /SF/{x_num}")与GetMapping("/SF/{x_num}")通过POSTMAN获得的值一样. 注意:G ...

  6. 三、zookeeper安装

    一.简介 二.下载解压: #wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar ...

  7. oracle11g安装教程完整版

    来自: https://www.2cto.com/database/201701/588135.html 64位WIN7+oracle11g+plsql安装 1.下载Oracle 11g R2 for ...

  8. easyui combobox 在datagrid中动态加载数据

    场景:datagrid 中用编辑框修改数据,有一个列使用的combobox  在可编辑的时候需要动态绑定数据,这个数据是在根据其他条件可变的 思路:在每次开启编辑框的时候动态绑定数据, datagri ...

  9. SQL Server 数据库try catch 存储过程

    SQL Server 在生产环境中这样写存储过程的坑都避免了吗? 原文链接: http://www.cnblogs.com/chenmh/p/7856777.html 概述 最近因为业务的需求写了一段 ...

  10. Spring Boot 构建电商基础秒杀项目 (五) 用户注册

    SpringBoot构建电商基础秒杀项目 学习笔记 UserService 添加 void register(UserModel userModel) throws BusinessException ...