Skip to content

Commit 0584063

Browse files
committed
统一管理项目的各个组件gradle配置
1 parent 8b16181 commit 0584063

5 files changed

Lines changed: 107 additions & 24 deletions

File tree

‎Common/build.gradle‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.2"
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
66

77
defaultConfig {
8-
minSdkVersion 15
9-
targetSdkVersion 25
10-
versionCode 1
11-
versionName "1.0"
12-
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
10+
versionCode rootProject.ext.versionCode
11+
versionName rootProject.ext.versionName
1312
}
13+
1414
buildTypes {
1515
release {
1616
minifyEnabled false
@@ -21,5 +21,20 @@ android {
2121

2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.android.support:appcompat-v7:25.1.0'
24+
//Android Support
25+
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
26+
compile "com.android.support:design:$rootProject.supportLibraryVersion"
27+
compile "com.android.support:percent:$rootProject.supportLibraryVersion"
28+
//网络请求相关
29+
compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
30+
compile "com.squareup.retrofit2:retrofit-mock:$rootProject.retrofitVersion"
31+
compile "com.github.franmontiel:PersistentCookieJar:$rootProject.cookieVersion"
32+
//稳定的
33+
compile "com.github.bumptech.glide:glide:$rootProject.glideVersion"
34+
compile "com.orhanobut:logger:$rootProject.loggerVersion"
35+
compile "org.greenrobot:eventbus:$rootProject.eventbusVersion"
36+
compile "com.google.code.gson:gson:$rootProject.gsonVersion"
37+
//不稳定的
38+
compile "com.github.mzule.activityrouter:activityrouter:$rootProject.routerVersion"
39+
compile "com.jude:easyrecyclerview:$rootProject.easyRecyclerVersion"
2540
}

‎Girls/build.gradle‎

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
1-
apply plugin: 'com.android.application'
1+
println isModule.toBoolean()
2+
if (isModule.toBoolean()) {
3+
apply plugin: 'com.android.application'
4+
} else {
5+
apply plugin: 'com.android.library'
6+
}
7+
8+
apply plugin: 'com.neenbedankt.android-apt'
29

310
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.2"
11+
compileSdkVersion rootProject.ext.compileSdkVersion
12+
buildToolsVersion rootProject.ext.buildToolsVersion
613

714
defaultConfig {
8-
applicationId "com.guiying.girls"
9-
minSdkVersion 15
10-
targetSdkVersion 25
11-
versionCode 1
12-
versionName "1.0"
13-
15+
minSdkVersion rootProject.ext.minSdkVersion
16+
targetSdkVersion rootProject.ext.targetSdkVersion
17+
versionCode rootProject.ext.versionCode
18+
versionName rootProject.ext.versionName
1419
}
20+
1521
buildTypes {
1622
release {
1723
minifyEnabled false
1824
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1925
}
2026
}
27+
28+
sourceSets {
29+
main {
30+
if (isModule.toBoolean()) {
31+
Manifest.srcFile 'src/main/debug/AndroidManifest.xml'
32+
} else {
33+
Manifest.srcFile 'src/main/release/AndroidManifest.xml'
34+
//release模式下排除debug文件夹中的所有Java文件
35+
java {
36+
exclude 'debug/**'
37+
}
38+
}
39+
}
40+
}
41+
//设置了resourcePrefix值后,所有的资源名必须以指定的字符串做前缀,否则会报错。
42+
//但是resourcePrefix这个值只能限定xml里面的资源,并不能限定图片资源,所有图片资源仍然需要手动去修改资源名。
43+
//resourcePrefix "girls_"
2144
}
2245

2346
dependencies {
2447
compile fileTree(dir: 'libs', include: ['*.jar'])
25-
compile 'com.android.support:appcompat-v7:25.1.0'
48+
compile project(':common')
49+
//router
50+
apt "com.github.mzule.activityrouter:compiler:$rootProject.aptCompilerVersion"
2651
}

‎build.gradle‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
mavenCentral()
67
}
7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.2'
98

9+
dependencies {
10+
classpath "com.android.tools.build:gradle:$localGradlePluginVersion"
11+
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
1012
// NOTE: Do not place your application dependencies here; they belong
1113
// in the individual module build.gradle files
1214
}
@@ -15,9 +17,42 @@ buildscript {
1517
allprojects {
1618
repositories {
1719
jcenter()
20+
mavenCentral()
21+
//Add the JitPack repository
22+
maven { url "https://jitpack.io" }
23+
//支持arr包
24+
flatDir {
25+
dirs 'libs'
26+
}
1827
}
1928
}
2029

2130
task clean(type: Delete) {
2231
delete rootProject.buildDir
2332
}
33+
34+
// Define versions in a single place
35+
ext {
36+
// Sdk and tools
37+
buildToolsVersion = localBuildToolsVersion
38+
compileSdkVersion = 25
39+
minSdkVersion = 15
40+
targetSdkVersion = 25
41+
versionCode = 1
42+
versionName = "1.0"
43+
javaVersion = JavaVersion.VERSION_1_8
44+
45+
// App dependencies version
46+
supportLibraryVersion = "25.1.0"
47+
retrofitVersion = "2.1.0"
48+
glideVersion = "3.7.0"
49+
loggerVersion = "1.15"
50+
eventbusVersion = "3.0.0"
51+
gsonVersion = "2.8.0"
52+
53+
//不成熟开源库,需经常检查升级版本
54+
aptCompilerVersion = "1.1.7"
55+
routerVersion = "1.2.1"
56+
easyRecyclerVersion = "4.3.4"
57+
cookieVersion = "v1.0.0"
58+
}

‎gradle.properties‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ org.gradle.jvmargs=-Xmx1536m
1414
# When configured, Gradle will run in incubating parallel mode.
1515
# This option should only be used with decoupled projects. More details, visit
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17-
# org.gradle.parallel=true
17+
org.gradle.daemon=true
18+
org.gradle.configureondemand=true
19+
org.gradle.parallel=true
20+
21+
localBuildToolsVersion=25.0.1
22+
localGradlePluginVersion=2.2.2
23+
24+
# 每次更改“isModule”的值后,需要Sync gradle
25+
isModule=false

‎settings.gradle‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include ':app',
2-
':Girls',
3-
':News',
4-
':Common'
2+
':girls',
3+
':news',
4+
':common'

0 commit comments

Comments
 (0)