Learning how to create a simple (native) executable script using Kotlin
-
Please install a standalone Kotlin compiler. If you are using
*Nix
, you can usebrew
with the following command in your console;brew install kotlin
-
Check if Kotlin compiler already installed with typing
kotlinc
in your console
-
Kotlin script has two different executables, you can use Kotlin compiler or Native compiler based on your needs 😄
-
If you are using Kotlin compiler, please create a Kotlin file with extension
.kts
and compile it in your console using the following command;kotlinc -script your_file.kts
-
If you are using Native compiler, please build the project using
gradle
wrapper command like this;./gradlew clean build
-
Then run the
.kexe
extension from your console using the following command;./gradlew runDebugExecutableMacos
./gradlew runReleaseExecutableMacos
-
For other operating system, please change the
suffix
instead 😄