-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.gradle.kts
72 lines (61 loc) · 2.28 KB
/
common.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
67
68
69
70
71
72
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
apply<CommonPlugin>()
class CommonPlugin : Plugin<Project> {
override fun apply(project: Project) = project.subprojects {
afterEvaluate {
when {
projectDir.parentFile != rootDir -> return@afterEvaluate
plugins.hasPlugin("com.android.application") -> configureApplication()
plugins.hasPlugin("com.android.library") -> configureLibrary()
}
}
}
private fun Project.configureApplication() {
extensions.configure<BaseAppModuleExtension>("android") {
compileSdk = COMPILE_SDK
defaultConfig {
minSdk = MIN_SDK
targetSdk = TARGET_SDK
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}
private fun Project.configureLibrary() {
extensions.configure<LibraryExtension>("android") {
compileSdk = COMPILE_SDK
defaultConfig {
minSdk = MIN_SDK
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}
private companion object {
const val COMPILE_SDK = 35
const val MIN_SDK = 21
const val TARGET_SDK = 35
}
}