forked from islamversity/Reyan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
161 lines (138 loc) · 5.97 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
buildscript {
apply from: "extras.gradle"
repositories {
google()
jcenter()
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
classpath "com.github.ben-manes:gradle-versions-plugin:0.36.0"
classpath "com.squareup.sqldelight:gradle-plugin:${Versions.sqlDelight}"
classpath "org.jetbrains.kotlin:kotlin-serialization:${Versions.kotlin}"
classpath "com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:0.5.1"
classpath 'co.touchlab:kotlinnativecocoapods:0.11'
classpath 'com.yandex.android:appmetrica-build-plugin:0.2.1'
}
}
plugins {
id("io.gitlab.arturbosch.detekt").version("1.0.0-RC16")
}
apply plugin: "com.github.ben-manes.versions"
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
maven {
url 'http://storage.googleapis.com/r8-releases/raw'
}
maven { url "https://dl.bintray.com/arrow-kt/arrow-kt/" }
maven { url "https://kotlin.bintray.com/kotlinx/" }
}
apply plugin: 'io.gitlab.arturbosch.detekt'
dependencies {
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.detekt}"
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget "1.8"
}
}
detekt {
toolVersion = Versions.detekt
input = files("src/main/kotlin")
filters = ".*/resources/.*,.*/build/.*"
config = files("detekt.yml")
}
ext {
def values = loadValues()
releaseKeyStoreAddress = values.getProperty('releaseKeyStoreAddress')
releaseKeyStorePass = values.getProperty('releaseKeyStorePass')
releaseKeyAlias = values.getProperty('releaseKeyAlias')
releaseKeyPass = values.getProperty('releaseKeyPass')
yandexAPIKey = values.getProperty('yandexAPIKey')
yandexPostKey = values.getProperty('yandexPostKey')
//there must be a local.properties files, at least to fill in the debug values
debugKeyStoreAddress = values.getProperty('debugKeyStoreAddress')
debugKeyStorePass = values.getProperty('debugKeyStorePass')
debugKeyAlias = values.getProperty('debugKeyAlias')
debugKeyPass = values.getProperty('debugKeyPass')
}
def loadValues() {
Properties localProperties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
}
//if running on CI fill the variables using environment
if (System.getenv("BITRISE_BUILD_TYPE") != null) {
loadPropertiesFromCI(localProperties)
return localProperties
}
if (localProperties.getProperty("releaseKeyStorePass") == null) {
//otherwise there should a local.properties file with debug values already set
String releaseKeyStoreAddress = localProperties.getProperty('debugKeyStoreAddress')
String releaseKeyStorePass = localProperties.getProperty('debugKeyStorePass')
String releaseKeyAlias = localProperties.getProperty('debugKeyAlias')
String releaseKeyPass = localProperties.getProperty('debugKeyPass')
String yandexAPIKey = ""
String yandexPostKey = ""
localProperties.setProperty('releaseKeyStoreAddress', releaseKeyStoreAddress)
localProperties.setProperty('releaseKeyStorePass', releaseKeyStorePass)
localProperties.setProperty('releaseKeyAlias', releaseKeyAlias)
localProperties.setProperty('releaseKeyPass', releaseKeyPass)
localProperties.setProperty('yandexAPIKey', yandexAPIKey)
localProperties.setProperty('yandexPostKey', yandexPostKey)
}
return localProperties
}
def loadPropertiesFromCI(localProperties) {
String buildType = System.getenv("BITRISE_BUILD_TYPE")
String keyStorePassEnvKey
String keyAliasEnvKey
String privateKeyPassEnvKey
String debugReleaseYandexAPIKey = "yandexAPIKey"
String debugReleaseYandexPostKey = "yandexPostKey"
if (buildType == "DEPLOY") {
keyStorePassEnvKey = "BITRISEIO_ANDROID_KEYSTORE_PASSWORD"
keyAliasEnvKey = "BITRISEIO_ANDROID_KEYSTORE_ALIAS"
privateKeyPassEnvKey = "BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD"
localProperties.setProperty('yandexAPIKey', System.getenv(debugReleaseYandexAPIKey))
localProperties.setProperty('yandexPostKey', System.getenv(debugReleaseYandexPostKey))
} else if (buildType == "PRIMARY") {
keyStorePassEnvKey = "DEBUG_KEYSTORE_PASSWORD"
keyAliasEnvKey = "DEBUG_KEY_ALIAS"
privateKeyPassEnvKey = "DEBUG_PRIVATE_KEY_PASSWORD"
localProperties.setProperty('yandexAPIKey', System.getenv(debugReleaseYandexAPIKey))
localProperties.setProperty('yandexPostKey', System.getenv(debugReleaseYandexPostKey))
} else if (buildType == "PULL_REQUEST") {
keyStorePassEnvKey = "PR_KEYSTORE_PASSWORD"
keyAliasEnvKey = "PR_KEY_ALIAS"
privateKeyPassEnvKey = "PR_PRIVATE_KEY_PASSWORD"
localProperties.setProperty('yandexAPIKey', "")
localProperties.setProperty('yandexPostKey', "")
} else {
throw IllegalArgumentException("buildType is not recognized")
}
String keyStoreAddress = System.getenv("HOME") + System.getenv("KEY_STORE_ADDRESS")
String keyStorePassword = System.getenv(keyStorePassEnvKey)
String keyAliasPassword = System.getenv(keyAliasEnvKey)
String privateKeyPassword = System.getenv(privateKeyPassEnvKey)
localProperties.setProperty('releaseKeyStoreAddress', keyStoreAddress)
localProperties.setProperty('debugKeyStoreAddress', keyStoreAddress)
localProperties.setProperty('releaseKeyStorePass', keyStorePassword)
localProperties.setProperty('debugKeyStorePass', keyStorePassword)
localProperties.setProperty('releaseKeyAlias', keyAliasPassword)
localProperties.setProperty('debugKeyAlias', keyAliasPassword)
localProperties.setProperty('releaseKeyPass', privateKeyPassword)
localProperties.setProperty('debugKeyPass', privateKeyPassword)
}