1
0

Use common versions

This commit is contained in:
2020-10-06 18:40:38 +02:00
parent f0155dea31
commit a1dde23fb3
2 changed files with 45 additions and 36 deletions
+8 -1
View File
@@ -1,5 +1,6 @@
package starter.config
import com.electronwill.nightconfig.core.UnmodifiableConfig
import com.electronwill.nightconfig.core.file.FileConfig
import starter.*
import com.electronwill.nightconfig.core.Config as NightConfig
@@ -19,13 +20,19 @@ class Config {
val cfg = FileConfig.of("config.toml")
cfg.load()
@Suppress("UNCHECKED_CAST")
val versions = cfg.get<UnmodifiableConfig>("versions").valueMap() as Map<String, String>
val dependencies = cfg.configMap("dependencies")
.map { (name, values) ->
val versionKey: String = values["version"] ?: name
val version = versions[versionKey] ?: error("Missing version for $name")
Dependency(
name,
values["groupId"],
values["artifactId"],
values["version"],
version,
values.getOrElse("default", false),
values.getEnumOrElse("category", Category.Other),
values.getEnumOrElse("scope", Scope.Compile),