forked from cyclestreets/android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
131 lines (109 loc) · 3.38 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
}
}
configure(subprojects.findAll { it.path.startsWith(':custom-versions:') ||
it.path.startsWith(':cyclestreets') }) {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'com.android.application'
signingKey(it)
manifestProperties(it)
versionProperties(it)
} // configure apks
configure(subprojects.findAll { it.path.startsWith(':libraries:') }) {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'com.android.library'
} // configure libraries
subprojects {
if (!file("${projectDir}/build.gradle").exists())
return
repositories {
jcenter()
}
android {
Properties appConfig = loadProperties("${rootDir}/config.properties")
compileSdkVersion appConfig['compileSdkVersion'].toInteger()
buildToolsVersion appConfig['toolsVersion']
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
minSdkVersion appConfig['minSdkVersion'].toInteger()
targetSdkVersion appConfig['targetSdkVersion'].toInteger()
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
} // packagingOptions
// Required due to strictness of the Android developer tools. See lint.xml for full details.
lintOptions {
lintConfig rootProject.file('gradle/lint.xml')
}
} // android
} // subprojects
def loadProperties(fileName) {
Properties props = new Properties()
props.load(new FileInputStream(file(fileName)))
return props;
} // loadProperties
def manifestProperties(project) {
def cyclestreetsDetails = project.file("cyclestreets.properties")
if (!cyclestreetsDetails.exists()) {
println ":${project.name}:No cyclestreets.properties"
return;
} // no cyclestreets props
project.android {
buildTypes {
all {
manifestPlaceholders = loadProperties(cyclestreetsDetails)
}
} // buildType
} // android
} // manifestProperties
def versionProperties(project) {
def versionDetails = project.file("version.properties")
def versionConfig = [ versionCode: "-1", versionName: "unknown" ]
if (versionDetails.exists())
versionConfig = loadProperties(versionDetails)
else
println ":${project.name}:No version.properties, using placeholder defaults"
project.android {
defaultConfig {
versionCode versionConfig['versionCode'].toInteger()
versionName versionConfig['versionName']
}
} // android
} // versionProperties
def signingKey(project) {
def licenseDetails = project.file("license.properties");
if (!licenseDetails.exists()) {
println ":${project.name}:No license.properties"
return;
} // licenseDetails.exists
Properties props = loadProperties(licenseDetails)
project.android {
signingConfigs {
release {
storeFile project.file(props['key.store'])
storePassword props['key.password']
keyAlias props['key.alias']
keyPassword props['key.password']
}
} // signingConfigs
buildTypes {
release {
signingConfig signingConfigs.release
}
} // buildTypes
} // android
} // signingKey