Skip to content

Spring like configuration for any kotlin application

License

Notifications You must be signed in to change notification settings

davidsth/kotlin-config

Repository files navigation

kotlin-config

Travis (.com) branch License

The goal is to provide a nice way to provide configuration to plain kotlin/java projects similar to how spring does it configuration.

Usage

Still in progress. However the goal is to use it as follows:

Given a yml property file:

# application-default.yml
name: MyApp
language: kotlin
id: 1

In any class that you'd like to "inject" a configuration, use the annotation as follows

@Config
class MarvelUniverse {
    init {
        println("name: ${MarvelUniverse_Config.name}")
        println("language: ${MarvelUniverse_Config.language}")
    }
}

fun main() {
    MarvelUniverse()
}

// outputs

name: MyApp
language: kotlin
id: 1

After compilation, a source file is generated to be used within the class named ClassName_Config.

Annotation processing has limitations where you cannot modify an existing class, so it's not a true "injection". The processor just creates a static output Class.


About

Spring like configuration for any kotlin application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages