Warning
This project has been archived and is no longer being actively developed by Elhub.
common-konfig is a simple, extensible type-safe API for adding configuration properties from multiple sources to a Kotlin/Java project.
A Kotlin or Java project.
Add the dependency to your project. For Gradle:
implementation("no.elhub.common:common-konfig:${konfig-version})
Or maven:
<dependency>
<groupId>no.elhub.common</groupId>
<artifactId>common-konfig</artifactId>
<version>${konfig_version}</version>
</dependency>
You can use common-konfig in a variety of ways, but the simplest way (in Kotlin) is simply to create an object that extends Configurable. For example:
import no.elhub.common.konfig.Configurable
import no.elhub.common.konfig.sources.ResourceFile
object MyConfiguration : Configurable(arrayOf(ResourceFile("my.properties"))) {
val aProperty = property<String>("aProperty")
val anotherProperty = property<Int>("another.property.with.weird.name")
val thirdProperty = property<String>("databasename")
}
The configurable takes a number of PropertySource objects, with the precedence of the objects in the array reflecting
the precedence the Configurable will give the properties in the code. Currently the project has only a few
sources that it can handle, but it is easy to add new ones by implementing them for the PropertySource
interface.
To test the module, run:
./gradlew test
See the open issues for a list of proposed features (and known issues).
This project still needs additional development to add support for more types, property sources, etc.
Contributing, issues and feature requests are welcome. See the Contributing file.
This project is developed by Elhub. For the specific development group responsible for this code, see the Codeowners file.
This project is MIT licensed.