Template for building CLI tool in Kotlin and producing native binary

Overview

Kotlin command-line native tool template

This template allows you to quickly build command-line tool using Kotlin , Clikt and build a native binary for your system.

It's using Kotlin JVM (not Kotlin Native) so you can use all those sweet Java libraries.

Setup

  • download and unpack GraalVM from their Github's releases site: https://github.com/graalvm/graalvm-ce-builds/releases (You don't need to replace your current JDK if you have one).
  • run <graalvm_dir>/Home/bin/gu install native-image to download native-image tool
  • in pom.xml set kotlin.compiler.jvmTarget and graalvm.version according to which GraalVM version you've downloaded

Now choose whether you want to build it only in your IDE or from your command-line:

IDE-only build setup

  • set the GraalVM as JDK in your IDE
  • setup Maven in your IDE if it's not working out-of-the-box
  • run Maven's clean package and make sure the IDE runs it with GraalVM

CLI setup

  • set GRAALVM_HOME environment variable to Home directory inside the unpacked GraalVM
  • install Maven if you don't have it and make sure it's on PATH
  • make sure Maven uses GraalVM JDK by running mvn -v
  • run build.sh in this project's parent directory

Build output

In both scenarios the native binary for the current system is generated in the /target directory. The name of the binary is the same as maven's project name set in pom.xml.

Run it like any other native binary: ./target/kt-example

You might also like...
A modular framework for building Discord bots in Kotlin using Kordex and Kord

Mik Bot A modular framework for building Discord bots in Kotlin using Kordex and Kord **If you are here for mikmusic, click here and there Deployment

Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers
Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers

Ktor Plugin Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers. Requires: https://github.com/Po

Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

A forkable starter for building your own recipes and deploying them on the Moderne SaaS

Rewrite recipe starter This repository serves as a template for building your own recipe JARs and publishing them to a repository where they can be ap

Meetups microservice, applying tactical DDD building blocks and in a real example.
Meetups microservice, applying tactical DDD building blocks and in a real example.

Meetups microservice: Applying tactical DDD Description This project is a practical example to understand the tactical patterns/building-blocks that d

Kotlin async server template with coroutines and zero deps

kotlin-server At attempt to very light-weight non-blocking http app template with support for Kotlin coroutines. Zero dependencies - Java built-in jdk

Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI
Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI

KMMNewsAPP There are two branches Main News App Main The main branch is a complete template that you can clone and use to build the awesome app that y

 KMMT : Kotlin Multiplatform Mobile Template
KMMT : Kotlin Multiplatform Mobile Template

Kotlin Multiplatform Mobile App Template

 Hexagonal Architecture Kotlin Template
Hexagonal Architecture Kotlin Template

The purpose of this template is to avoid repeating, over and over again, the same basic packages structure, gradle and configurations.

Owner
Ryszard Grodzicki
Ryszard Grodzicki
An AutoValue extension that generates binary and source compatible equivalent Kotlin data classes of AutoValue models.

AutoValue Kotlin auto-value-kotlin (AVK) is an AutoValue extension that generates binary-and-source-compatible, equivalent Kotlin data classes. This i

Slack 19 Aug 5, 2022
A Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server

dadb Blog Post: Our First Open-Source Project A Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server de

mobile.dev 791 Dec 20, 2022
This is a template to help you get started building amazing Kotlin applications and libraries.

Welcome to the Starter This is a template to help you get started building amazing Kotlin applications and libraries. Over time, examples will be comp

Backbone 8 Nov 4, 2022
A lightweight tool for managing and building Kotlin projects.

kpm kpm (Kotlin Project Manager) is a lightweight tool for managing and building Kotlin projects. What is kpm? Essentially, kpm is going to be a light

Conor Byrne 5 Apr 23, 2022
FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose, Android's modern toolkit for building native UI.

FirestoreCleanArchitectureApp FirestoreCleanArchitectureApp is an app built with Kotlin and Cloud Firestore that displays data in real-time using Andr

Alex 66 Dec 15, 2022
Kotlin cli maven spring failsafe findbugs cucumber mockito junit car data

Kotlin cli maven spring failsafe findbugs cucumber mockito junit car data

null 0 Feb 1, 2022
Kotlin CLI utilities, mostly intended for use with Clikt

Kotlin CLI Utils A repo containing basic CLI utilities for Kotlin. Installation dependencies { implementation("com.slack.cli:kotlin-cli-util:<versio

Slack 21 Jan 2, 2023
InstaKiller - InstaKiller is a CLI client for Instagram

InstaKiller InstaKiller is a CLI wrapper around instagram4j library. Icon Item ?

null 10 Apr 5, 2022
Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

JetBrains 10k Jan 7, 2023
Building Web Applications with React and Kotlin JS Hands-On Lab

Building Web Applications with React and Kotlin JS Hands-On Lab This repository is the code corresponding to the hands-on lab Building Web Application

Brian Donnoe 0 Nov 13, 2021