Create New Module

This guide outlines how to add a new module to the project using baselines convention plugins.

1. Choose the Layer

Determine where your module belongs to maintain architectural separation:

LayerPurpose
uiFeature screens, navigation, theming.
domainBusiness logic, use-case orchestration, rules.
dataRepository implementations, network, database.
toolkitReusable utilities, DI, logging, crypto, etc.

Action: Create a directory under the chosen layer (e.g., ui/profile).


2. Configure the Module

Choose the type of module you are building below.

🅰️ Option A: Multiplatform Module (Android + iOS)

Standard choice for most logic and UI.

1. Create build.gradle.kts Create the file inside your new directory and paste the following content.

kotlin
1import io.baselines.gradle.multiplatform.androidLibrary
2
3plugins {
4 alias(libs.plugins.baselines.multiplatform.kotlin)
5 alias(libs.plugins.baselines.multiplatform.android.library)
6 // Only needed if this module contains UI/Compose code
7 alias(libs.plugins.baselines.compose)
8}
9
10// 1. Set your specific namespace
11androidLibrary("com.example.ui.profile")
12
13// 2. Define dependencies
14kotlin {
15 sourceSets {
16 commonMain.dependencies {
17 // Shared dependencies
18 }
19 androidMain.dependencies {
20 // Android specific
21 }
22 iosMain.dependencies {
23 // iOS specific
24 }
25 }
26}

2. Create Folder Structure Create the source folders matching your namespace (e.g., com/example/ui/profile):

text
1📂 src
2 ┣ 📂 commonMain/kotlin/com/example/ui/profile
3 ┣ 📂 androidMain/kotlin/com/example/ui/profile
4 ┗ 📂 iosMain/kotlin/com/example/ui/profile

🅱️ Option B: Android-Only Module

Use for platform-specific features (e.g., Google Services, Camera, Splash).

1. Create build.gradle.kts Create the file inside your new directory and paste the following content.

kotlin
1import io.baselines.gradle.android.androidLibrary
2
3plugins {
4 alias(libs.plugins.baselines.android.library)
5 // Only needed if this module contains UI/Compose code
6 alias(libs.plugins.baselines.compose)
7}
8
9// 1. Set your specific namespace
10androidLibrary("com.example.ui.profile")
11
12// 2. Define dependencies
13dependencies {
14 // Android dependencies
15}

2. Create Folder Structure Create the standard Android source folder matching your namespace:

text
1📂 src
2 ┗ 📂 main/kotlin/com/example/ui/profile