-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbuild.gradle
executable file
·236 lines (189 loc) · 6.68 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
buildscript { scriptHandler ->
apply from: "${projectDir}/gradle/versions.gradle"
apply from: "${projectDir}/gradle/repositories.gradle", to: scriptHandler
}
plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.kapt"
id "com.mikepenz.aboutlibraries.plugin"
id "com.github.ben-manes.versions"
id "io.gitlab.arturbosch.detekt"
id "org.jlleitschuh.gradle.ktlint"
}
apply from: "${projectDir}/gradle/utils.gradle"
android {
compileSdkVersion rootProject.ext.compileSdkVersion
ndkVersion rootProject.ext.ndkVersion
dexOptions {
preDexLibraries !isCI()
}
defaultConfig {
applicationId "me.proxer.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode appVersionMajor * 1000000 + appVersionMinor * 10000 + appVersionPatch * 100
versionName "$appVersionMajor.$appVersionMinor.$appVersionPatch"
vectorDrawables.useSupportLibrary true
resConfigs "de"
javaCompileOptions {
annotationProcessorOptions {
if (project.property("kapt.incremental.apt").toBoolean() == true) {
arguments << ["room.incremental": "true"]
}
arguments << ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
sourceSets {
main {
java.srcDirs += "src/main/kotlin"
}
debug {
java.srcDirs += "src/debug/kotlin"
}
release {
java.srcDirs += "src/release/kotlin"
}
logRelease {
java.srcDirs = release.java.srcDirs
res.srcDirs = release.res.srcDirs
}
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
signingConfigs {
if (shouldSign()) {
release {
storeFile file(getFromSecrets("RELEASE_STORE_FILE"))
storePassword getFromSecrets("RELEASE_STORE_PASSWORD")
keyAlias getFromSecrets("RELEASE_KEY_ALIAS")
keyPassword getFromSecrets("RELEASE_KEY_PASSWORD")
}
}
}
buildTypes {
if (!shouldSign() && !isCI()) {
logger.warn("This build will not be signed because it is missing the keystore info. Please add " +
"values for \"RELEASE_STORE_FILE\", \"RELEASE_STORE_PASSWORD\", \"RELEASE_KEY_ALIAS\" and " +
"\"RELEASE_KEY_PASSWORD\" to your secrets.properties file if you want the apk to be signed.")
}
debug {
multiDexEnabled true
ndk { abiFilters "arm64-v8a", "armeabi-v7a", "x86_64", "x86" }
versionNameSuffix = "-debug"
buildConfigField "String", "PROXER_API_KEY", "\"${getFromSecrets("PROXER_API_KEY")}\""
buildConfigField "boolean", "LOG", "Boolean.parseBoolean(\"true\")"
}
release {
postprocessing {
obfuscate true
optimizeCode true
removeUnusedCode true
removeUnusedResources true
proguardFile "config/shrinker/shrinker-rules.pro"
}
multiDexEnabled true
ndk { abiFilters "arm64-v8a", "armeabi-v7a", "x86_64", "x86" }
buildConfigField "String", "PROXER_API_KEY", "\"${getFromSecrets("PROXER_API_KEY")}\""
buildConfigField "boolean", "LOG", "Boolean.parseBoolean(\"false\")"
if (shouldSign()) {
signingConfig signingConfigs.release
}
}
logRelease {
postprocessing {
obfuscate true
optimizeCode true
removeUnusedCode true
removeUnusedResources true
proguardFile "config/shrinker/shrinker-rules.pro"
}
multiDexEnabled true
ndk { abiFilters "arm64-v8a", "armeabi-v7a", "x86_64", "x86" }
versionNameSuffix = "-logRelease-${getGitHash()}"
buildConfigField "String", "PROXER_API_KEY", "\"${getFromSecrets("PROXER_API_KEY")}\""
buildConfigField "boolean", "LOG", "Boolean.parseBoolean(\"true\")"
if (shouldSign()) {
signingConfig signingConfigs.release
}
}
}
lintOptions {
mkdir("$buildDir/reports/lint")
warningsAsErrors = true
checkReleaseBuilds = false
lintConfig file("$rootDir/config/lint/lint.xml")
xmlOutput file("$buildDir/reports/lint/lint-results.xml")
htmlOutput file("$buildDir/reports/lint/lint-results.html")
}
packagingOptions {
jniLibs {
useLegacyPackaging false
}
exclude "META-INF/*.kotlin_module"
exclude "META-INF/*.version"
exclude "META-INF/rxkotlin.properties"
exclude "META-INF/proguard/**"
exclude "META-INF/README.md"
exclude "META-INF/nanohttpd/**"
exclude "kotlin/**"
exclude "kotlinx/**"
exclude "third_party/**"
exclude "jsr305_annotations/**"
exclude "error_prone/**"
exclude "auto/**"
exclude "build-data.properties"
exclude "androidsupportmultidexversion.txt"
exclude "play-services-*.properties"
}
bundle {
language {
enableSplit = false
}
}
applicationVariants.all { variant ->
def suffix = variant.buildType.name == "release" ? "-release" : ""
variant.outputs.all {
outputFileName = "app-${variant.versionName}${suffix}.apk"
}
}
}
apply from: "${projectDir}/gradle/repositories.gradle"
apply from: "${projectDir}/gradle/dependencies.gradle"
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = javaVersion.toString()
freeCompilerArgs = ["-Xjsr305=strict", "-progressive", "-Xnew-inference"]
}
}
kapt {
useBuildCache = true
}
detekt {
version = detektPluginVersion
buildUponDefaultConfig = true
config = files("$projectDir/config/detekt/detekt.yml")
reports {
xml.destination = file("$buildDir/reports/detekt/detekt.xml")
html.destination = file("$buildDir/reports/detekt/detekt.html")
}
}
ktlint {
version = ktlintVersion
disabledRules = ["import-ordering"]
reporters {
reporter org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE
}
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
it.candidate.version.contains("alpha")
}
}
wrapper {
gradleVersion rootProject.ext.gradleVersion
}