From 0bf8f969445a324ecc491075c44bc792e4807b9b Mon Sep 17 00:00:00 2001 From: Pavlo Stavytskyi Date: Sun, 29 Oct 2023 01:15:25 -0700 Subject: [PATCH] added more android metadata properties --- .../kotlin/io/morfly/airin/AndroidMetadata.kt | 7 +++++- .../morfly/airin/AndroidProjectDecorator.kt | 22 ++++++++++++++++++- .../airin/feature/AndroidBinaryFeature.kt | 15 ++++++++----- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidMetadata.kt b/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidMetadata.kt index 4dc24296..f49ae020 100644 --- a/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidMetadata.kt +++ b/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidMetadata.kt @@ -5,7 +5,12 @@ import java.io.Serializable data class AndroidMetadata( val applicationId: String?, val packageName: String?, - val composeEnabled: Boolean + val composeEnabled: Boolean, + val minSdkVersion: Int?, + val compileSdkVersion: Int?, + val targetSdkVersion: Int?, + val versionCode: Int?, + val versionName: String? ): Serializable { companion object { diff --git a/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidProjectDecorator.kt b/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidProjectDecorator.kt index 7ed0cf37..9605a9e9 100644 --- a/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidProjectDecorator.kt +++ b/airin-gradle-android/src/main/kotlin/io/morfly/airin/AndroidProjectDecorator.kt @@ -22,7 +22,12 @@ open class AndroidProjectDecorator : GradleProjectDecorator { androidMetadata = AndroidMetadata( applicationId = target.applicationId, packageName = target.namespace ?: target.manifestPackageName, - composeEnabled = target.composeEnabled + composeEnabled = target.composeEnabled, + minSdkVersion = target.minSdkVersion, + compileSdkVersion = target.compileSdkVersion, + targetSdkVersion = target.targetSdkVersion, + versionCode = target.versionCode, + versionName = target.versionName ) } } @@ -36,6 +41,21 @@ val Project.composeEnabled: Boolean val Project.applicationId: String? get() = extensions.findByType(ApplicationExtension::class.java)?.defaultConfig?.applicationId +val Project.minSdkVersion: Int? + get() = extensions.findByType(CommonExtension::class.java)?.defaultConfig?.minSdk + +val Project.targetSdkVersion: Int? + get() = extensions.findByType(ApplicationExtension::class.java)?.defaultConfig?.targetSdk + +val Project.compileSdkVersion: Int? + get() = extensions.findByType(CommonExtension::class.java)?.compileSdk + +val Project.versionCode: Int? + get() = extensions.findByType(ApplicationExtension::class.java)?.defaultConfig?.versionCode + +val Project.versionName: String? + get() = extensions.findByType(ApplicationExtension::class.java)?.defaultConfig?.versionName + val Project.androidManifestFile: File? get() = extensions.findByType(BaseExtension::class.java) ?.sourceSets diff --git a/airin-gradle-android/src/main/kotlin/io/morfly/airin/feature/AndroidBinaryFeature.kt b/airin-gradle-android/src/main/kotlin/io/morfly/airin/feature/AndroidBinaryFeature.kt index ecbcb2e5..31534f8c 100644 --- a/airin-gradle-android/src/main/kotlin/io/morfly/airin/feature/AndroidBinaryFeature.kt +++ b/airin-gradle-android/src/main/kotlin/io/morfly/airin/feature/AndroidBinaryFeature.kt @@ -3,6 +3,7 @@ package io.morfly.airin.feature import io.morfly.airin.FeatureContext import io.morfly.airin.GradleFeatureComponent import io.morfly.airin.GradleProject +import io.morfly.airin.androidMetadata import io.morfly.airin.module.AndroidLibraryModule import io.morfly.pendant.starlark.android_binary import io.morfly.pendant.starlark.lang.context.BuildContext @@ -22,12 +23,14 @@ abstract class AndroidBinaryFeature : GradleFeatureComponent() { incremental_dexing = 1 manifest = "src/main/AndroidManifest.xml" manifest_values = dict { - "applicationId" to "io.morfly.airin.sample" - "minSdkVersion" to "24" - "targetSdkVersion" to "34" - "compileSdkVersion" to "34" - "versionCode" to "1" - "versionName" to "1.0" + val data = packageDescriptor.androidMetadata + + "applicationId" to data?.applicationId + "minSdkVersion" to data?.minSdkVersion?.toString() + "targetSdkVersion" to data?.targetSdkVersion?.toString() + "compileSdkVersion" to data?.compileSdkVersion?.toString() + "versionCode" to data?.versionCode?.toString() + "versionName" to data?.versionName } multidex = "native" deps = list[":${packageDescriptor.name}"]