Hoplite

screenshot of Hoplite

A boilerplate-free Kotlin config library for loading configuration files as data classes

Overview

Hoplite is a Kotlin library that allows you to load configuration files into typesafe classes in a boilerplate-free way. By using Kotlin data classes, you can define your config and Hoplite will read from one or more config files at startup, mapping the values into your config classes. Hoplite supports multiple formats including Yaml, JSON, Toml, Hocon, and Java .props files. It also supports property sources for system overrides, and provides support for custom data types and cascading config files. Hoplite also offers beautiful errors for easy debugging and support for config reloads.

Features

  • Multiple formats: Hoplite supports multiple formats including Yaml, JSON, Toml, Hocon, and Java .props files.
  • Property Sources: Per-system overrides can be done using JVM system properties, environment variables, JNDI, or a per-user local config file.
  • Batteries included: Hoplite supports many standard types such as primitives, enums, dates, collection types, inline classes, uuids, nullable types, as well as popular Kotlin third party library types.
  • Custom Data Types: The Decoder interface allows you to add support for custom domain types or standard library types not covered out of the box.
  • Cascading: Config files can be stacked, allowing you to have a default config file and then an environment specific file.
  • Beautiful errors: Detailed error messages are provided for easy debugging.
  • Preprocessors: Hoplite supports several preprocessors that replace placeholders with values resolved from external configs, such as AWS Secrets Manager or Azure KeyVault.
  • Reloadable config: Config reloads can be triggered on a fixed interval or in response to external events.

Summary

Hoplite is a versatile Kotlin library for loading configuration files into typesafe classes. It supports multiple formats, property sources, custom data types, cascading config files, and more. With Hoplite, you can easily define and manage your config in a boilerplate-free way. Debugging is made easy with detailed error messages and support for preprocessors. Hoplite also offers config reloads on a fixed interval or in response to external events. Overall, Hoplite simplifies the process of handling config files in Kotlin applications.