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
Starts a simple HTTP server providing following endpoints:
GET /actuator/health
- Returns OKGET /actuator/info
- Returns some infos like version, commit, JVM version, etc.POST /actuator/gc
- Run GCPOST /actuator/shutdown
- Shutdown application
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 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 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.
Following libraries are used:
The build process is configured using Gradle Kotlin DSL.
- 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)
- 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, ...
- 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