Skip to content

Simple example application to explore the Kotlin programming language.

License

Notifications You must be signed in to change notification settings

mrkuz/hello-kotlin

Repository files navigation

General

Simple example application to explore the Kotlin programming language.

This project is set up as Gradle multi-project build, consisting of two subprojects:

  • app: The actual application
  • lib: Common utilities and functions used by the application

Application

Starts a simple HTTP server providing following endpoints:

  • GET /actuator/health - Returns OK
  • GET /actuator/info - Returns some infos like version, commit, JVM version, etc.
  • POST /actuator/gc - Run GC
  • POST /actuator/shutdown - Shutdown application

Library

The code was written for educational purposes. Don't expect full-flegded production-ready implementations.

Provides basic building blocks for applications, including

  • Logging
  • Loading HOCON, YAML and property files from classpath
  • Dependency injection
  • Profiles
  • Event bus
  • Task scheduling
  • NIO HTTP server
  • Development mode

Profiles

Profiles can be used to control the behaviour of the application in different environments. The active profile is read from the environment variable BNB1_PROFILE. If not set, 'default' is used.

gradle run activates the profile 'dev'.

Development mode

Development mode watches the source directory for changes and stops the application if a file is modified, added or deleted. This is intended to be used with gradle run -t to trigger compilation and restart on code changes.

Testing

Following libraries are used:

Build

The build process is configured using Gradle Kotlin DSL.

Used Gradle plugins

  • Versions: Checks for dependency updates (Link))
  • Dokka: Creates KDoc documentation (Link)
  • Shadow: Creates Fat Jar (Link)
  • Jib: Containerizes app (Link)
  • Test Logger: Prints test logs to console (Link)
  • kotlinx.benchmark: Runs JMH benchmarks (Link)
  • Ktlint Gradle: Runs ktlint (Link)

Custom extensions

  • There is a file 'project.properties' in the root direcotry, which is used for build configuration
  • Building the project creates a file 'build.properties', with information like timestamp, commit, ...

Useful Gradle tasks

  • List all tasks: ./gradlew tasks
  • Clean: ./gradlew clean
  • Check for dependency updates: ./gradlew dependencyUpdates
  • Run application: ./gradlew run
  • Continuous run: ./gradlew run -t
  • Run ktlint: ./gradlew ktlintCheck
  • Run detekt: ./gradlew detekt
  • Run tests: ./gradlew test
  • Run benchmarks: ./gradlew benchmark
  • Build project and create JAR: ./gradlew build
  • Build Docker image: ./gradlew jibDockerBuild
  • Build documentation: ./gradlew dokkaHtml
  • Update Gradle wrapper: ./gradlew wrapper --gradle-version=X.Y.Z

About

Simple example application to explore the Kotlin programming language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages