heitorcolangelo
02/28/2024, 5:33 PM.
└── Library/
├── shared/
│ ├── featureA (module)/
│ │ └── build.gradle.kts
│ ├── featureB (module)/
│ │ └── build.gradle.kts
│ └── src/commonMain/kotlin/com/example/library/
│ └── Library.kt
└── build.gradle.kts
The shared/src/build.gradle.kts
depends on both featureA
and featureB
, and it also contains the publishing configurations, like below:
plugins {
// Other plugins
id("maven-publish")
}
group = "com.example"
version = "1.0"
publishing {
repositories {
mavenLocal()
}
}
kotlin {
androidTarget {
// Other configs
publishLibraryVariants("release")
}
// Other configs
sourceSets {
commonMain.dependencies {
api(projects.shared.featureA)
api(projects.shared.featureB)
}
}
}
After running the publishAndroidReleasePublicationToMavenLocalRepository
gradle task, the artefacts are properly created, and I can add this dependency to my Android project, like below:
implementation("com.example:shared-android:1.0")
However, I can only access the classes that are inside shared/src
and not the ones in featureA
or featureB
. Unless I also publish them as a separate library and import them into the Android project.
What I expect is to publish a single artefact where I can access all the exposed classes/interfaces that are declared as api
dependencies in the shared/src/build.gradle.kts
Does anyone know if this is feasible?Pablichjenkov
02/28/2024, 5:46 PMheitorcolangelo
02/28/2024, 6:06 PMktor-client-core
and ktor-client-cio
.
These modules depend on several others, but you don't have to import them into your project; for example, the ktor-client-cio
gradle file depends on:
• ktor-client-core
• ktor-http-cio
• ktor-shared:ktor-websockets
• ktor-network:ktor-network-tls
Maybe I do have to publish all of them, and then Gradle will resolve their dependency? 🤔heitorcolangelo
02/28/2024, 6:45 PMpublishToMavenLocal
to publish all the defined target artefacts, and in the Android project, I can use shared:1.0
instead of shared-android:1.0
.
But I guess that if I just need the Android library, I can use only the publishAndroidReleasePublication
and publishKotlinMultiplatformPublication
tasks to generate the artefacts I need.Pablichjenkov
02/28/2024, 7:19 PMPablichjenkov
02/28/2024, 7:20 PMPablichjenkov
02/28/2024, 7:22 PMPablichjenkov
02/28/2024, 7:23 PMheitorcolangelo
02/28/2024, 9:39 PMAshu Tyagi
03/01/2024, 4:38 AMPablichjenkov
03/01/2024, 5:25 AMAshu Tyagi
03/01/2024, 1:11 PMPablichjenkov
03/01/2024, 1:49 PMAshu Tyagi
03/01/2024, 2:18 PM