Konture: The Importance of Dual Views in Kotlin Architecture Testing
A tool that validates alignment between Gradle and source code in Kotlin projects.
1The Kotlin Architecture Dilemma
Kotlin projects often face mismatches between Gradle dependency graphs and actual source code structures. For example, in Android projects, presentation layer directly using transport DTOs can manifest differently in module dependencies versus source imports.
2Limitations of Existing Tools
While tools like ArchUnit work well for JVM bytecode analysis, they can't fully cover Kotlin's multiplatform capabilities. Source scanners analyzing package structures often ignore Gradle module hierarchies, leaving critical architectural rules unenforced in KMP projects.
3Konture's Differentiator
Konture provides a test surface that understands both Gradle module structure and Kotlin source model. It can simultaneously check forbidden feature module dependencies and Android API accesses from commonMain, preserving true architectural boundaries through dual-view analysis.
4Real-World Implementations
In complex setups like Now in Android's 36 Gradle modules or KotlinConf KMP's 9 platform modules, single-view tools fail to enforce complete architectural rules. Konture bridges this gap by analyzing both inter-module dependencies and source imports holistically.
5Cost of Architectural Debt
Initially harmless local solutions (like one feature directly calling another) accumulate technical debt over time. Konture aims to detect such cross-dependencies early, especially preserving code reusability in multiplatform projects.
6Bytecode Analysis Gaps
Kotlin features like top-level functions or inline members have different bytecode representations. Konture understands source-level architectural impacts of these constructs where pure bytecode analysis lacks context.
7Source Scanner Shortcomings
Folder structures don't always reflect Gradle module hierarchies. Konture discerns between 'api' folders versus 'api' modules, accurately enforcing dependency boundaries in Android and KMP projects.
8Beyond Linters
While detekt and ktlint handle code style, Konture answers system-wide questions: 'Does this module depend on forbidden siblings?' or 'Is this public API leaking implementation details?' - addressing architectural integrity rather than formatting.
9Dual-View Model
Konture's build view analyzes Gradle modules and dependencies, while its source view examines files and declarations. This combination proves critical for detecting platform-specific leaks or expect/actual mismatches in KMP.
10Evolution of Arch Testing
Where traditional tools focus on post-compilation or pure source analysis, Konture addresses Kotlin's unique needs. It offers a novel approach to enforcing architectural decisions in large-scale, multiplatform codebases.
11Integration Patterns
Konture integrates as dedicated test modules in reference projects like Now in Android, allowing teams to incorporate architectural checks into CI/CD pipelines and maintain integrity as codebases grow.
12Advancing Kotlin Ecosystem
Konture emerges as a critical tool for realizing Kotlin's multiplatform potential. By bridging Gradle and source realities, it helps large teams maintain architectural discipline in complex projects.
Original article: ProAndroidDev - Medium — Konture: Kotlin Mimari Testlerinde İki Görünümün Önemi