🧠 D: DOCUMENT — Problem & Opportunity
Some SKaiNET Kotlin Multiplatform modules manually recreate source-set relationships already provided by Kotlin’s default hierarchy template.
Examples include:
skainet-backend-api
skainet-backend-cpu
These modules manually create and connect source sets such as:
commonMain
└── nativeMain
├── appleMain
│ ├── iosMain
│ └── macosMain
└── linuxMain
skainet-backend-cpu also explicitly disables the default template:
kotlin.mpp.applyDefaultHierarchyTemplate=false
This duplicates Kotlin Gradle Plugin behavior and makes the hierarchy harder to maintain. It also prevents modules from automatically receiving newer hierarchy changes, such as the shared webMain source set for JS and WasmJS targets.
The repository already contains a better pattern in skainet-io-core: apply the default hierarchy first, then add only genuinely custom source sets such as native64Main.
Relevant files:
Summary:
Replace manually duplicated standard Kotlin Multiplatform hierarchy wiring with the default hierarchy template, while preserving documented custom source-set relationships where required.
🔍 A: ASSESS — Feasibility & Impact
✔️ Feasibility
The migration should be straightforward for modules whose manual hierarchy matches Kotlin’s standard hierarchy.
The existing source directories should continue to work because source sets such as nativeMain, appleMain, iosMain, macosMain, and linuxMain are provided by the default template when matching targets are declared.
Modules with special requirements must be assessed separately. For example, skainet-backend-native-cpu may require custom wiring because of native cinterop commonization.
✔️ Expected Impact
- Reduce duplicated Gradle configuration.
- Automatically inherit future Kotlin hierarchy improvements.
- Enable the standard
webMain hierarchy for JS and WasmJS targets.
- Reduce hierarchy-related Gradle warnings.
- Make custom source sets easier to identify and understand.
- Reduce maintenance when targets are added or removed.
✔️ Risks / Constraints
- Published Gradle metadata must remain compatible.
- Native cinterop source sets may require custom target grouping.
- Custom groups such as
native64Main must not be removed.
- Compilation and publication tasks must be checked across all supported targets.
- Moving dependencies into
webMain should be handled separately unless required by the migration.
✔️ Dependencies
No new dependency is required.
The migration depends on the Kotlin Gradle Plugin already used by the project.
Relevant documentation:
📚 R: RESEARCH — What Must Be Understood First?
Research Tasks
Open Questions
- Should shared JS and WasmJS dependencies be moved into
webMain as part of this issue?
- Does any downstream consumer rely on the existing published source-set metadata?
- Can
skainet-backend-native-cpu use the default linuxMain hierarchy?
- Should the default hierarchy policy be enforced through a convention plugin?
🛠️ C: CODE — Implementation Plan
Development Tasks
Acceptance Criteria
💬 Additional Notes
The migration should distinguish between:
-
Standard hierarchy duplicated manually
Remove the manual wiring and use Kotlin’s default template.
-
Genuinely custom hierarchy
Apply the default template first, then add only the custom source sets or relationships required by SKaiNET.
skainet-io-core already demonstrates this approach by using the default hierarchy together with the custom native64Main and native64Test source sets.
🧠 D: DOCUMENT — Problem & Opportunity
Some SKaiNET Kotlin Multiplatform modules manually recreate source-set relationships already provided by Kotlin’s default hierarchy template.
Examples include:
skainet-backend-apiskainet-backend-cpuThese modules manually create and connect source sets such as:
skainet-backend-cpualso explicitly disables the default template:kotlin.mpp.applyDefaultHierarchyTemplate=falseThis duplicates Kotlin Gradle Plugin behavior and makes the hierarchy harder to maintain. It also prevents modules from automatically receiving newer hierarchy changes, such as the shared
webMainsource set for JS and WasmJS targets.The repository already contains a better pattern in
skainet-io-core: apply the default hierarchy first, then add only genuinely custom source sets such asnative64Main.Relevant files:
Summary:
🔍 A: ASSESS — Feasibility & Impact
✔️ Feasibility
The migration should be straightforward for modules whose manual hierarchy matches Kotlin’s standard hierarchy.
The existing source directories should continue to work because source sets such as
nativeMain,appleMain,iosMain,macosMain, andlinuxMainare provided by the default template when matching targets are declared.Modules with special requirements must be assessed separately. For example,
skainet-backend-native-cpumay require custom wiring because of native cinterop commonization.✔️ Expected Impact
webMainhierarchy for JS and WasmJS targets.✔️ Risks / Constraints
native64Mainmust not be removed.webMainshould be handled separately unless required by the migration.✔️ Dependencies
No new dependency is required.
The migration depends on the Kotlin Gradle Plugin already used by the project.
Relevant documentation:
📚 R: RESEARCH — What Must Be Understood First?
Research Tasks
dependsOn.webMainandwebTestare generated for JS and WasmJS targets.Open Questions
webMainas part of this issue?skainet-backend-native-cpuuse the defaultlinuxMainhierarchy?🛠️ C: CODE — Implementation Plan
Development Tasks
kotlin.mpp.applyDefaultHierarchyTemplate=falsewhere it is no longer required.skainet-backend-api.skainet-backend-cpu.webMainandwebTestare created where applicable.native64Main.Acceptance Criteria
webMainhierarchy.💬 Additional Notes
The migration should distinguish between:
Standard hierarchy duplicated manually
Remove the manual wiring and use Kotlin’s default template.
Genuinely custom hierarchy
Apply the default template first, then add only the custom source sets or relationships required by SKaiNET.
skainet-io-corealready demonstrates this approach by using the default hierarchy together with the customnative64Mainandnative64Testsource sets.