-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
66 lines (57 loc) · 1.83 KB
/
build.gradle.kts
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
import com.android.build.gradle.AppExtension
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
plugins {
alias(libs.plugins.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.com.android.library) apply false
alias(libs.plugins.detekt) version libs.versions.detekt
alias(libs.plugins.kover) version libs.versions.kover
}
subprojects {
project.plugins.configureAppAndModules(project = project)
apply(from = buildscripts("detekt.gradle"))
apply(from = buildscripts("setup.gradle"))
plugins.apply("org.jetbrains.kotlinx.kover")
}
fun PluginContainer.configureAppAndModules(project: Project) = apply {
whenPluginAdded {
when (this) {
is AppPlugin -> {
project.extensions
.getByType<AppExtension>()
.apply { applyAppCommons() }
}
is LibraryPlugin -> {
project.extensions
.getByType<LibraryExtension>()
.apply { applyLibraryCommons() }
}
}
}
}
fun AppExtension.applyAppCommons() {
applyBaseCommons()
defaultConfig.apply {
// versionName here is static because we don't want to break incremental builds.
// versionName must be changed ONLY from gradle task, iff buildType is release/demo.
versionName = Versions.APP_VERSION_NAME
}
}
fun LibraryExtension.applyLibraryCommons() {
applyBaseCommons()
}
fun BaseExtension.applyBaseCommons() {
compileSdkVersion(Versions.COMPILE_SDK_VERSION)
defaultConfig.apply {
minSdk = Versions.MIN_SDK_VERSION
targetSdk = Versions.TARGET_SDK_VERSION
versionCode = Versions.APP_VERSION_CODE
}
compileOptions.apply {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}