Want to write a native cli application, but do not want to write it in C/C++? Do not want users to think about installing SDK (like Python, JDK/JRE, etc.) and related dependencies? You can easily and quickly write your application using Kotlin MPP and have Native executables using this template! All boilerplate is already done in this template, so no need to spend days on the boring work and on the setup of environment, all you need - to implement business logic.
We did this boring work for you, so don't forget to give a star to this project to save it in your list! ⭐
✅ Github actions build/release scripts to Central and Github Releases
✅ Gradle build/release tasks for Kotlin MPP
✅ Code analysis enabled with a full GitHub integration
✅ Junit testing report integration with Github
✅ Nice and easy code generation for cli from a config file
✅ Application that is based on kotlinx.cli
✅ Utility methods for a cli application
- Create a new repository based on this template using Github:
Use this template
->Create a new repository
; - Replace everywhere 'kotlin-mpp-cli' to your name of the project;
- Replace 'com.akuleshov7.cli' to your package domain name in code and directory names (!);
- Run
CliPropertiesTest.kt
on JVM to check that everything is setup correctly; - Add your cli options to
buildSrc/src/main/resources/config-options.json
(andconfig-arguments.json
); - Once the project is built (
./gradlew build
), OptionsTable.md,CliProperties.kt
files will be generated; - Implement the business logic of your application in
core
module (BusinessLogic
class); - Do not forget to change Publishing configuration (license, git url, etc.) in
PublishingConfiguration.kt
; - Add publishing credentials for Maven central to GitHub:
OSSRH_USERNAME
,OSSRH_PASSWORD
,GPG_SEC
,GPG_PASSWORD
. Read more here.
- To build project:
./gradlew build
- To run diktat auto-fix:
./gradlew diktatFix
- To run detekt:
./gradlew detektAll
Main part of the code is written in Kotlin common module. This means that it can be built for each and every Kotlin native platform. However, to reduce the scope, kotlin-mpp-cli now supports only the following platforms:
- jvm
- mingwx64
- linuxx64
- macosx64
- macosArm64 (M1+)
🌐 latest supported Kotlin version: 1.8
Main modules:
- cli: contains
main
method and cli-related things - common: common logic like data models and so on
- core: core business logic and a framework (if any)
JB still has a limited support to MPP projects, so you probably will have problems while indexing of this project in IDE. Known problems:
CliProperties
probably can be ignored by indexing and marked as unknown dependency;main
method is not runnable out of the box in IDE, but you can run it using run-configuration.
Special thanks to those developers who help us to make this project: @akuleshov7 @petertrr