Harish Reddy
09/16/2024, 10:35 AMCoreModule
Module-2: FeatureModule
FeatureModule
references CoreModule
internally using api(project(path = ":CoreModule))
. The final artifact FeatureModule
after publishing to maven/maven local is supposed to be integrated in main Android app.
So, now my expectation is to have the code within CoreModule
to be accessible inside the main Android app since FeatureModule
includes the CoreModule
. But, I can’t access the code/classes within CoreModule
inside the main Android app. This is a KMP project which I am not so familiar with. So, not sure if it is a KMP thing or something else. Any idea what could be missing in this setup? I am attaching reference code in the thread.Harish Reddy
09/16/2024, 10:35 AM======build.gradle.kts=========
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
id("maven-publish")
id("com.example.kmpproject.library")
}
kmpProjectLibrary {
publishedArtifactId.set("FeatureModule")
}
kotlin {
androidTarget {
publishLibraryVariants("release")
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
val xcf = XCFramework()
listOf(iosArm64(), iosSimulatorArm64()).forEach {
it.binaries.framework {
export(project(":CoreModule"))
xcf.add(this)
baseName = "FeatureModule"
isStatic = true
binaryOption("bundleId", "com.example.kmmproject.FeatureModule")
}
}
sourceSets {
commonMain.dependencies {
implementation(libs.ktor.client.core)
// Including CoreModule
api(project(path = ":CoreModule"))
}
androidMain.dependencies {
// Including CoreModule
api(project(path = ":CoreModule"))
}
iosMain.dependencies {
implementation(libs.ktor.client.darwin)
}
}
}
android {
}
Harish Reddy
09/16/2024, 10:36 AMclass LibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
val extension =
extensions.create<LibraryConventionPluginExtension>("kmmLibrary")
configureArtifactoryPublishing {
try {
extension.publishedArtifactId.get()
} catch (exception: MissingValueException) {
null
}
}
}
}
private fun Project.configureArtifactoryPublishing(artifactIdProvider: () -> String?) {
configure<LibraryExtension> {
configure<PublishingExtension> {
publishing {
repositories {
maven {
url = "sample url"
version = "1.0"
group = "com.example.kmm"
credentials {
username = properties["USERNAME"] as? String ?: ""
password = properties["PASSWORD"] as? String ?: ""
}
}
}
}
}
}
}
}
Pablichjenkov
09/17/2024, 9:55 PMPablichjenkov
09/17/2024, 9:57 PMHarish Reddy
09/17/2024, 10:10 PMPablichjenkov
09/18/2024, 9:26 PMHarish Reddy
09/18/2024, 9:34 PM