Skip to content

Commit

Permalink
added more android metadata properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfly committed Oct 29, 2023
1 parent 1db6dce commit 0bf8f96
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"]
Expand Down

0 comments on commit 0bf8f96

Please sign in to comment.