1+ @file:Suppress(" UnstableApiUsage" )
2+
3+ package extensions
4+
5+ import Config
6+ import com.android.build.api.dsl.CommonExtension
7+ import org.gradle.api.JavaVersion
8+ import org.gradle.api.Project
9+ import org.gradle.api.artifacts.VersionCatalog
10+ import org.gradle.api.plugins.ExtensionAware
11+ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
12+
13+ internal fun CommonExtension <* , * , * , * >.setupPackingOptions () {
14+ packagingOptions {
15+ with (resources) {
16+ with (pickFirsts) {
17+ add(" META-INF/library_release.kotlin_module" )
18+ add(" META-INF/LICENSE.md" )
19+ add(" META-INF/LICENSE-notice.md" )
20+ }
21+ with (excludes) {
22+ add(" META-INF/AL2.0" )
23+ add(" META-INF/LGPL2.1" )
24+ }
25+ }
26+ }
27+ }
28+
29+ internal fun CommonExtension <* , * , * , * >.setupAndroidDefaultConfig () {
30+ defaultConfig {
31+ compileSdk = Config .compileSdkVersion
32+ minSdk = Config .minSdkVersion
33+ vectorDrawables.useSupportLibrary = true
34+
35+ testInstrumentationRunner = Config .testInstrumentationRunner
36+ }
37+ }
38+
39+ internal fun CommonExtension <* , * , * , * >.setupCompileOptions () {
40+ compileOptions {
41+ sourceCompatibility = JavaVersion .VERSION_11
42+ targetCompatibility = JavaVersion .VERSION_11
43+ }
44+
45+ kotlinOptions {
46+ jvmTarget = " 11"
47+ }
48+ }
49+
50+ fun CommonExtension <* , * , * , * >.setupCompose (catalog : VersionCatalog ) {
51+ buildFeatures {
52+ compose = true
53+ }
54+
55+ composeOptions {
56+ kotlinCompilerExtensionVersion = " ${catalog.getVersion(" compose" )} "
57+ }
58+
59+ packagingOptions {
60+ resources.excludes.apply {
61+ add(" META-INF/AL2.0" )
62+ add(" META-INF/LGPL2.1" )
63+ }
64+ }
65+ }
66+
67+
68+ internal fun CommonExtension <* , * , * , * >.setupNameSpace (project : Project ) {
69+ val moduleName = project.displayName
70+ .removePrefix(" project " )
71+ .replace(" :" , " ." )
72+ .replace(" '" , " " )
73+ .replace(" -" , " ." )
74+
75+ namespace = " ${Config .applicationId}$moduleName "
76+ }
77+
78+ private fun CommonExtension <* , * , * , * >.kotlinOptions (block : KotlinJvmOptions .() -> Unit ) {
79+ (this as ExtensionAware ).extensions.configure(" kotlinOptions" , block)
80+ }
0 commit comments