Skip to content

Commit 83a8208

Browse files
committed
Added gradle configurations
1 parent c954c37 commit 83a8208

File tree

5 files changed

+160
-27
lines changed

5 files changed

+160
-27
lines changed

app/build.gradle

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,39 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 25
6-
buildToolsVersion "25.0.3"
5+
def globalConfiguration = rootProject.extensions.getByName("ext")
6+
7+
compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
8+
buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")
79
defaultConfig {
8-
applicationId "com.androidarchitecture"
9-
minSdkVersion 15
10-
targetSdkVersion 25
11-
versionCode 1
12-
versionName "1.0"
13-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
10+
minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
11+
targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
12+
13+
applicationId globalConfiguration.getAt("androidApplicationId")
14+
versionCode globalConfiguration.getAt("androidVersionCode")
15+
versionName globalConfiguration.getAt("androidVersionName")
16+
testInstrumentationRunner globalConfiguration.getAt("testInstrumentationRunner")
17+
testApplicationId globalConfiguration.getAt("testApplicationId")
18+
}
19+
20+
packagingOptions {
21+
exclude 'LICENSE.txt'
22+
exclude 'META-INF/DEPENDENCIES'
23+
exclude 'META-INF/ASL2.0'
24+
exclude 'META-INF/NOTICE'
25+
exclude 'META-INF/LICENSE'
26+
}
27+
28+
lintOptions {
29+
quiet true
30+
abortOnError false
31+
ignoreWarnings true
32+
disable 'InvalidPackage' //Some libraries have issues with this.
33+
disable 'OldTargetApi' //Lint gives this warning but SDK 20 would be Android L Beta.
34+
disable 'IconDensities' //For testing purpose. This is safe to remove.
35+
disable 'IconMissingDensityFolder' //For testing purpose. This is safe to remove.
1436
}
37+
1538
buildTypes {
1639
release {
1740
minifyEnabled false
@@ -30,29 +53,35 @@ kapt {
3053

3154

3255
dependencies {
56+
def dependencies = rootProject.ext.dependencies
57+
def testDependencies = rootProject.ext.testDependencies
58+
3359
compile fileTree(dir: 'libs', include: ['*.jar'])
34-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
60+
androidTestCompile(testDependencies.espresso, {
3561
exclude group: 'com.android.support', module: 'support-annotations'
3662
})
3763

38-
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
39-
40-
compile 'android.arch.lifecycle:runtime:1.0.0-alpha1'
41-
compile 'android.arch.lifecycle:extensions:1.0.0-alpha1'
42-
compile 'android.arch.persistence.room:runtime:1.0.0-alpha1'
43-
compile 'com.android.support:appcompat-v7:25.3.1'
44-
compile 'com.android.support:design:25.3.1'
45-
compile 'com.google.dagger:dagger:2.4'
46-
compile 'com.squareup.retrofit2:retrofit:2.0.0'
47-
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
48-
compile 'com.google.code.gson:gson:2.7'
49-
compile 'com.android.support.constraint:constraint-layout:1.0.2'
50-
testCompile 'junit:junit:4.12'
51-
kapt 'android.arch.lifecycle:compiler:1.0.0-alpha1'
52-
kapt 'android.arch.persistence.room:compiler:1.0.0-alpha1'
53-
kapt 'com.google.dagger:dagger-compiler:2.4'
54-
provided 'org.glassfish:javax.annotation:10.0-b28'
55-
provided 'javax.annotation:jsr250-api:1.0'
64+
compile dependencies.kotlin
65+
66+
compile dependencies.runtime
67+
compile dependencies.extensions
68+
compile dependencies.roomRuntime
69+
kapt dependencies.lifecycleCompiler
70+
kapt dependencies.roomCompiler
71+
72+
compile dependencies.dagger
73+
kapt dependencies.daggerCompiler
74+
provided dependencies.glassfish
75+
provided dependencies.jsr250
76+
77+
compile dependencies.appcompat
78+
compile dependencies.design
79+
compile dependencies.constraintLayout
80+
81+
compile dependencies.retrofit
82+
compile dependencies.converterGson
83+
compile dependencies.gson
84+
testCompile testDependencies.junit
5685
}
5786
repositories {
5887
mavenCentral()

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
apply from: 'build_configuration/ci.gradle'
3+
apply from: 'build_configuration/dependencies.gradle'
24

35
buildscript {
46
ext.kotlin_version = '1.1.2-4'
@@ -19,6 +21,14 @@ allprojects {
1921
jcenter()
2022
maven { url 'https://maven.google.com' }
2123
}
24+
25+
ext {
26+
androidApplicationId = 'com.androidarchitecture'
27+
androidVersionCode = 1
28+
androidVersionName = "1.0"
29+
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
30+
testApplicationId = 'com.androidarchitecture.test'
31+
}
2232
}
2333

2434
task clean(type: Delete) {

build_configuration/ci.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def ciServer = 'TRAVIS'
2+
def executingOnCI = "true" == System.getenv(ciServer)
3+
4+
// Since for CI we always do full clean builds, we don't want to pre-dex
5+
// See http://tools.android.com/tech-docs/new-build-system/tips
6+
subprojects {
7+
project.plugins.whenPluginAdded { plugin ->
8+
if ('com.android.build.gradle.AppPlugin' == plugin.class.name ||
9+
'com.android.build.gradle.LibraryPlugin' == plugin.class.name) {
10+
project.android.dexOptions.preDexLibraries = !executingOnCI
11+
}
12+
}
13+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
allprojects {
2+
repositories {
3+
jcenter()
4+
}
5+
}
6+
7+
ext {
8+
//Kotlin
9+
kotlin_version = '1.1.2-4'
10+
11+
//Android
12+
androidBuildToolsVersion = "25.0.3"
13+
androidCompileSdkVersion = 25
14+
androidMinSdkVersion = 17
15+
androidSupportLibVersion = '25.3.1'
16+
androidTargetSdkVersion = 25
17+
18+
//Libraries
19+
arch = '1.0.0-alpha1'
20+
gson = '2.7'
21+
converterGson = '2.1.0'
22+
retrofit = '2.0.0'
23+
daggerVersion = '2.4'
24+
glassfish = '10.0-b28'
25+
jsr250 = '1.0'
26+
constraintLayout = '1.0.2'
27+
28+
//Testing
29+
robolectricVersion = '3.1.1'
30+
jUnitVersion = '4.12'
31+
assertJVersion = '1.7.1'
32+
mockitoVersion = '1.9.5'
33+
dexmakerVersion = '1.0'
34+
espressoVersion = '2.0'
35+
testingSupportLibVersion = '0.1'
36+
37+
//Development
38+
leakCanaryVersion = '1.3.1'
39+
40+
dependencies = [
41+
kotlin: "org.jetbrains.kotlin:kotlin-stdlib-jre7:${kotlin_version}",
42+
43+
runtime: "android.arch.lifecycle:runtime:${arch}",
44+
extensions: "android.arch.lifecycle:extensions:${arch}",
45+
roomRuntime: "android.arch.persistence.room:runtime:${arch}",
46+
lifecycleCompiler: "android.arch.lifecycle:compiler:${arch}",
47+
roomCompiler: "android.arch.persistence.room:compiler:${arch}",
48+
49+
dagger: "com.google.dagger:dagger:${daggerVersion}",
50+
daggerCompiler: "com.google.dagger:dagger-compiler:${daggerVersion}",
51+
glassfish: "org.glassfish:javax.annotation:${glassfish}",
52+
jsr250: "javax.annotation:jsr250-api:${jsr250}",
53+
54+
appcompat: "com.android.support:appcompat-v7:${androidSupportLibVersion}",
55+
design: "com.android.support:design:${androidSupportLibVersion}",
56+
57+
retrofit: "com.squareup.retrofit2:retrofit:${retrofit}",
58+
converterGson: "com.squareup.retrofit2:converter-gson:${converterGson}",
59+
gson: "com.google.code.gson:gson:${gson}",
60+
constraintLayout: "com.android.support.constraint:constraint-layout:${constraintLayout}"
61+
]
62+
63+
testDependencies = [
64+
dexmaker: "com.google.dexmaker:dexmaker:${dexmakerVersion}",
65+
dexmakerMockito: "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}",
66+
espresso: "com.android.support.test.espresso:espresso-core:${espressoVersion}",
67+
testingSupportLib: "com.android.support.test:testing-support-lib:${testingSupportLibVersion}",
68+
69+
junit: "junit:junit:${jUnitVersion}",
70+
assertj: "org.assertj:assertj-core:${assertJVersion}",
71+
mockito: "org.mockito:mockito-core:${mockitoVersion}",
72+
robolectric: "org.robolectric:robolectric:${robolectricVersion}",
73+
]
74+
75+
developmentDependencies = [
76+
leakCanary: "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}",
77+
]
78+
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ org.gradle.jvmargs=-Xmx1536m
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
1717
# org.gradle.parallel=true
18+
org.gradle.daemon=true
19+
org.gradle.parallel=true
20+
org.gradle.configureondemand=true

0 commit comments

Comments
 (0)