Skip to content

Commit

Permalink
fix #7: build.gradle 统一配置改进
Browse files Browse the repository at this point in the history
  • Loading branch information
金良善 authored and 金良善 committed Oct 23, 2017
1 parent 9c3ae62 commit bd5a091
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 85 deletions.
5 changes: 2 additions & 3 deletions adapter/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apply plugin: 'com.android.library'


dependencies {
compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile support.support_v4
compile support.recyclerview
}
24 changes: 7 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@ dependencies {
compile project(":util")

/******* support 包 ****************************************************************************/
compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"

/******* 应用权限库 ****************************************************************************/
// compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'
compile support.support_v4
compile support.appcompat
compile support.recyclerview
compile support.design
compile support.cardview

/******* 其它常用库 ****************************************************************************/
compile "com.jude:swipebackhelper:$rootProject.ext.swipebackhelperVersion"

// 常用 utils
compile "com.blankj:utilcode:$rootProject.ext.utilcodeVersion"

/******* 内存泄漏 ****************************************************************************/
// debugCompile "com.squareup.leakcanary:leakcanary-android:$rootProject.ext.leakcanaryVersion"
// releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$rootProject.ext.leakcanaryVersion"
// testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$rootProject.ext.leakcanaryVersion"
compile swipebackhelper
compile utilcode
}
12 changes: 6 additions & 6 deletions base-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ apply plugin: 'com.android.library'
dependencies {
compile project(":adapter")

compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile support.support_v4
compile support.recyclerview

compile "com.trello.rxlifecycle2:rxlifecycle:$rootProject.ext.rxlifecycleVersion"
compile rx.rxlifecycle
// If you want to bind to Android-specific lifecycles
compile "com.trello.rxlifecycle2:rxlifecycle-android:$rootProject.ext.rxlifecycleVersion"
compile "com.trello.rxlifecycle2:rxlifecycle-components:$rootProject.ext.rxlifecycleVersion"
compile rx.rxlifecycle_android
compile rx.rxlifecycle_components

compile "com.liaoinstan.springview:library:$rootProject.ext.springViewVersion"
compile springview
}
36 changes: 18 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// 导入 external 全局变量
apply from: "ext.gradle"

buildscript {
println("${project.name}: buildscript")

// rootProject.buildscript 里用的变量, 由于调用时机比 "闭包project.ext{ ... }" 早, 故不能写在那边
project.ext.kotlin_version = "1.1.3-2"
project.ext.android_plugin_version = "2.2.0"
// project.ext.kotlin_version = "1.1.3-2"
// project.ext.android_plugin_version = "2.2.0"
// 导入 external 全局变量
apply from: "ext.gradle"

repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$project.ext.android_plugin_version"
classpath _android.plugin

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.ext.kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$project.ext.kotlin_version"
classpath _kotlin.kotlin_gradle_plugin
classpath _kotlin.kotlin_android_extensions
}
}

Expand All @@ -41,17 +41,17 @@ subprojects {
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion as Integer
buildToolsVersion rootProject.ext.buildToolsVersion as String
compileSdkVersion _android.compileSdkVersion as Integer
buildToolsVersion _android.buildToolsVersion as String

defaultConfig {
if(isAppModule)
applicationId "com.fashare.mvvm_juejin"

minSdkVersion rootProject.ext.minSdkVersion as Integer
targetSdkVersion rootProject.ext.targetSdkVersion as Integer
versionCode rootProject.ext.versionCode as Integer
versionName rootProject.ext.versionName as String
minSdkVersion _android.minSdkVersion as Integer
targetSdkVersion _android.targetSdkVersion as Integer
versionCode _android.versionCode as Integer
versionName _android.versionName as String
}

buildTypes {
Expand All @@ -74,12 +74,12 @@ subprojects {

dependencies {
// kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
kapt "com.android.databinding:compiler:$rootProject.ext.android_plugin_version"
compile _kotlin.kotlin_stdlib
kapt databindingCompiler

/******* rx ****************************************************************************/
compile "io.reactivex.rxjava2:rxjava:$rootProject.ext.rxjavaVersion" //1.3MB [EventBus]
compile "io.reactivex.rxjava2:rxandroid:$rootProject.ext.rxandroidVersion" //8KB
// rxjava
compile rx.rxjava2
compile rx.rxandroid2
}
}

Expand Down
10 changes: 5 additions & 5 deletions databinding/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dependencies {
compile project(":adapter")

/******* support 包 ****************************************************************************/
compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"
compile support.support_v4
compile support.appcompat
compile support.recyclerview
compile support.design
compile support.cardview
}
93 changes: 66 additions & 27 deletions ext.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,79 @@ println("${project.name}: apply ext")
// 以下写法为闭包, 可能不会立即赋值
project.ext{
println("${project.name}: init ext")
// kotlin_version = "1.1.3-2"
// android_plugin_version = "2.2.0"

compileSdkVersion = 24
buildToolsVersion = '24.0.1'
def androidPluginVersion = "2.2.0"
_android = [
plugin: "com.android.tools.build:gradle:$androidPluginVersion",

minSdkVersion = 15
targetSdkVersion = 24
versionCode = 1
versionName = "1.0"
compileSdkVersion : 24,
buildToolsVersion : '24.0.1',

// App dependencies
supportLibraryVersion = "25.3.1"
minSdkVersion : 15,
targetSdkVersion : 24,
versionCode : 1,
versionName : "1.0"
]

rxjavaVersion = "2.1.0"
rxandroidVersion = "2.0.1"
rxpermissionsVersion = "0.9.4@aar"
rxlifecycleVersion = "2.1.0"
// kotlin
def kotlinVersion = "1.1.3-2"
_kotlin = [
// plugins
kotlin_gradle_plugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion",
kotlin_android_extensions: "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion",

okhttp3Version = "3.8.0"
retrofitVersion = "2.3.0"
retrofit2rxjava2Version = "1.0.0"
gsonVersion = "2.7"
klogVersion = "1.6.0"
// libs
kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
]

leakcanaryVersion = "1.5.1"
// UI
def supportLibraryVersion = "25.3.1"
support = [
support_v4: "com.android.support:support-v4:$supportLibraryVersion",
appcompat: "com.android.support:appcompat-v7:$supportLibraryVersion",
recyclerview: "com.android.support:recyclerview-v7:$supportLibraryVersion",
design: "com.android.support:design:$supportLibraryVersion",
cardview: "com.android.support:cardview-v7:$supportLibraryVersion"
]
springview = "com.liaoinstan.springview:library:1.3.0"
swipebackhelper = "com.jude:swipebackhelper:3.1.2"

glideVersion = "3.7.0"
glideTransformationsVersion = "2.0.1"
glideOkhttp3IntegrationVersion = "1.4.0@aar"
databindingCompiler = "com.android.databinding:compiler:$androidPluginVersion"

eventbusVersion = "2.4.0"
swipebackhelperVersion = "3.1.2"
utilcodeVersion = "1.9.0"
// rx
def rxjavaVersion = "2.1.0"
def rxandroidVersion = "2.0.1"
rx = [
rxjava2: "io.reactivex.rxjava2:rxjava:$rxjavaVersion",
rxandroid2: "io.reactivex.rxjava2:rxandroid:$rxandroidVersion",
rxlifecycle: "com.trello.rxlifecycle2:rxlifecycle:$rxjavaVersion",
rxlifecycle_android: "com.trello.rxlifecycle2:rxlifecycle-android:$rxjavaVersion",
rxlifecycle_components: "com.trello.rxlifecycle2:rxlifecycle-components:$rxjavaVersion",

springViewVersion = "1.3.0"
rxpermissions: 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'
]

// net
def okhttp3Version = "3.8.0"
okhttp3 = [
logging_interceptor: "com.squareup.okhttp3:logging-interceptor:$okhttp3Version",
]
def retrofitVersion = "2.3.0"
retrofit2 = [
retrofit: "com.squareup.retrofit2:retrofit:$retrofitVersion",
adapter_rxjava2: "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion",
converter_gson: "com.squareup.retrofit2:converter-gson:$retrofitVersion"
]
gson = "com.google.code.gson:gson:2.7"
klog = "com.github.zhaokaiqiang.klog:library:1.6.0"

def glideVersion = "3.7.0"
glide = [
glide: "com.github.bumptech.glide:glide:$glideVersion",
glide_transformations: "jp.wasabeef:glide-transformations:2.0.1",
okhttp3_integration: "com.github.bumptech.glide:okhttp3-integration:1.4.0@aar"
]

// other
utilcode = "com.blankj:utilcode:1.9.0"
}
6 changes: 3 additions & 3 deletions imageloader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies {
compile project(":net")

/******* 网络图片库 ****************************************************************************/
compile "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
compile "jp.wasabeef:glide-transformations:$rootProject.ext.glideTransformationsVersion"
compile "com.github.bumptech.glide:okhttp3-integration:$rootProject.ext.glideOkhttp3IntegrationVersion"
compile glide.glide
compile glide.glide_transformations
compile glide.okhttp3_integration
}
10 changes: 5 additions & 5 deletions net/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

/******* 网络请求库 ****************************************************************************/
compile "com.squareup.okhttp3:logging-interceptor:$rootProject.ext.okhttp3Version"
compile "com.squareup.retrofit2:retrofit:$rootProject.ext.retrofitVersion"
compile "com.squareup.retrofit2:adapter-rxjava2:$rootProject.ext.retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$rootProject.ext.retrofitVersion"
compile okhttp3.logging_interceptor
compile retrofit2.retrofit
compile retrofit2.adapter_rxjava2
compile retrofit2.converter_gson

compile "com.github.zhaokaiqiang.klog:library:$rootProject.ext.klogVersion"
compile klog
}
2 changes: 1 addition & 1 deletion util/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'com.android.library'

dependencies {
compile "com.google.code.gson:gson:$rootProject.ext.gsonVersion"
compile gson
}

0 comments on commit bd5a091

Please sign in to comment.