kltemplate is a modern Kotlin Multiplatform library template designed to accelerate the development of cross-platform applications and libraries. It provides a robust, modular, and scalable foundation for targeting Android, JVM, and Web (WASM/JS) platforms using a single codebase.
The template leverages the latest Kotlin Multiplatform, Compose Multiplatform, and Gradle conventions, with a focus on clean architecture, testability, and developer experience.
- Kotlin Multiplatform: Shared business logic across Android, JVM, and Web (WASM/JS).
- Compose Multiplatform UI: Unified UI code for all supported platforms.
- Modular Architecture: Clear separation of features and core modules.
- CI/CD Ready: GitHub Actions workflows for build, test, and release.
- Code Quality: Integrated Detekt, Spotless, and Kover for linting, formatting, and code coverage.
- Benchmarking: Macrobenchmark and Baseline Profile support for Android.
- Easy Dependency Management: Centralized via
libs.versions.toml. - Sample App: Example usage for all supported targets.
- Documentation & Changelog: Well-documented code and automated changelog management.
.
├── app/ # Multiplatform application entry points
├── library/ # Shared library modules (UI, model, etc.)
├── benchmarks/ # Android macrobenchmark and baseline profile
├── build-logic/ # Gradle convention plugins and build scripts
├── kotlin-js-store/ # JS-specific modules (if any)
├── gradle/ # Gradle wrapper and version catalogs
├── spotless/ # Formatting configuration
├── README.md
├── CHANGELOG.md
└── ...
- JDK 21+
- Android Studio Giraffe+
- Node.js (for JS/WASM target)
- Gradle 8.0+ (wrapper included)
git clone https://github.com/mshdabiola/kltemplate.git
cd kltemplateBuild all targets:
./gradlew buildBuild and run the Android app:
./gradlew :app:installDebug
adb shell am start -n com.hobit.sample/.MainActivityBuild and run the JVM desktop app:
./gradlew :app:runJvmBuild and run the WASM/JS app (served locally):
./gradlew :app:jsBrowserDevelopmentRun- Clone or use as a GitHub template to start your own multiplatform project.
- Rename packages and update module names as needed.
- Add your business logic to
library/and UI toapp/.
If you publish modules from library/, consumers can add dependencies via Maven Central or GitHub Packages (see Publishing).
- app: Entry points for Android, JVM, and WASM/JS.
- library: Shared UI components, models, and utilities.
- benchmarks: Android macrobenchmark and baseline profile tests.
- build-logic: Custom Gradle plugins for convention-driven builds.
- Follows Kotlin Coding Conventions.
- Run formatting and lint checks before committing:
./gradlew spotlessCheck detektRun all tests:
./gradlew testRun Compose UI tests (Android):
./gradlew :library:connectedAndroidTestGenerate and collect baseline profiles:
./gradlew :benchmarks:connectedAndroidTestThe template is pre-configured for publishing to Maven Central and GitHub Packages. Update groupId, versionName, and credentials in gradle/libs.versions.toml and GitHub secrets.
To publish:
./gradlew publishContributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Open issues for bugs or feature requests.
- Submit pull requests with clear descriptions and tests.
This project is licensed under the Apache 2.0 License.