Skip to content

Commit 51261fd

Browse files
committed
chore(build): derive kmp library android namespace from path
1 parent 4bf5b14 commit 51261fd

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

build-plugin/plugin/src/main/kotlin/net/thunderbird/gradle/plugin/library/kmp/KotlinMultiplatformExtension.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package net.thunderbird.gradle.plugin.library.kmp
22

33
import com.android.build.api.dsl.KotlinMultiplatformAndroidLibraryTarget
4+
import net.thunderbird.gradle.plugin.ProjectConfig
45
import org.gradle.api.Action
56
import org.gradle.api.NamedDomainObjectContainer
67
import org.gradle.api.NamedDomainObjectProvider
8+
import org.gradle.api.Project
79
import org.gradle.api.artifacts.ExternalModuleDependency
810
import org.gradle.api.artifacts.MinimalExternalModuleDependency
911
import org.gradle.api.plugins.ExtensionAware
@@ -20,6 +22,17 @@ fun KotlinMultiplatformExtension.android(configure: Action<KotlinMultiplatformAn
2022
(this as ExtensionAware).extensions.configure("android", configure)
2123
}
2224

25+
fun KotlinMultiplatformAndroidLibraryTarget.namespaceByPath(project: Project) {
26+
val pathSegments = project.path.split(':')
27+
.filter { it.isNotBlank() }
28+
.flatMap { it.split('-') }
29+
.filter { it.isNotBlank() }
30+
31+
namespace = listOf(ProjectConfig.group)
32+
.plus(pathSegments)
33+
.joinToString(separator = ".")
34+
}
35+
2336
/**
2437
* Creates a dependency with the given configuration.
2538
*

build-plugin/plugin/src/main/kotlin/net/thunderbird/gradle/plugin/library/kmp/LibraryKmpPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class LibraryKmpPlugin : Plugin<Project> {
4444
}
4545

4646
android {
47+
namespaceByPath(target)
4748
minSdk = ProjectConfig.Android.sdkMin
4849
compileSdk = ProjectConfig.Android.sdkCompile
4950

build-plugin/plugin/src/main/kotlin/net/thunderbird/gradle/plugin/library/kmp/compose/LibraryKmpComposePlugin.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package net.thunderbird.gradle.plugin.library.kmp.compose
33
import net.thunderbird.gradle.plugin.ProjectConfig
44
import net.thunderbird.gradle.plugin.library.kmp.android
55
import net.thunderbird.gradle.plugin.library.kmp.androidHostTest
6+
import net.thunderbird.gradle.plugin.library.kmp.namespaceByPath
67
import net.thunderbird.gradle.plugin.libs
78
import org.gradle.api.Plugin
89
import org.gradle.api.Project
@@ -48,6 +49,7 @@ class LibraryKmpComposePlugin : Plugin<Project> {
4849
}
4950

5051
android {
52+
namespaceByPath(target)
5153
minSdk = ProjectConfig.Android.sdkMin
5254
compileSdk = ProjectConfig.Android.sdkCompile
5355

components/core/outcome/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,3 @@ plugins {
22
alias(libs.plugins.tb.library.kmp)
33
alias(libs.plugins.testBalloon)
44
}
5-
6-
kotlin {
7-
@Suppress("UnstableApiUsage")
8-
android {
9-
namespace = "net.thunderbird.components.core.outcome"
10-
}
11-
}

0 commit comments

Comments
 (0)