TheElectronWill / night-config

Powerful java configuration library for toml, yaml, hocon, json and in-memory configurations. Serialization/deserialization framework.
GNU Lesser General Public License v3.0
242 stars 28 forks source link

Toml: can't parse gradle version catalog #174

Closed murdos closed 6 months ago

murdos commented 6 months ago

The gradle documentation uses this example:

[versions]
groovy = "3.0.5"
checkstyle = "8.37"

[libraries]
groovy-core = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" }
groovy-json = { module = "org.codehaus.groovy:groovy-json", version.ref = "groovy" }
groovy-nio = { module = "org.codehaus.groovy:groovy-nio", version.ref = "groovy" }
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version = { strictly = "[3.8, 4.0[", prefer="3.9" } }

[bundles]
groovy = ["groovy-core", "groovy-json", "groovy-nio"]

[plugins]
versions = { id = "com.github.ben-manes.versions", version = "0.45.0" }

Parsing this file (with FileConfig.builder(tomlVersionCatalogFile).sync().build().load();) generates an error :

com.electronwill.nightconfig.core.io.ParsingException: Invalid separator '.'after key "version" in some table.
        at com.electronwill.nightconfig.toml.TableParser.checkInvalidSeparator(TableParser.java:95)
        at com.electronwill.nightconfig.toml.TableParser.parseInline(TableParser.java:29)
        at com.electronwill.nightconfig.toml.ValueParser.parse(ValueParser.java:31)
        at com.electronwill.nightconfig.toml.ValueParser.parse(ValueParser.java:69)
        at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:57)
        at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:101)
        at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:121)
        at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:55)
        at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:120)
        at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:244)
        at com.electronwill.nightconfig.core.file.SyncFileConfig.lambda$load$1(SyncFileConfig.java:91)
        at com.electronwill.nightconfig.core.concurrent.ConcurrentCommentedConfig.lambda$bulkCommentedUpdate$1(ConcurrentCommentedConfig.java:144)
        at com.electronwill.nightconfig.core.concurrent.SynchronizedConfig.bulkCommentedUpdate(SynchronizedConfig.java:189)
        at com.electronwill.nightconfig.core.concurrent.ConcurrentCommentedConfig.bulkCommentedUpdate(ConcurrentCommentedConfig.java:143)
        at com.electronwill.nightconfig.core.file.SyncFileConfig.load(SyncFileConfig.java:90)
sciwhiz12 commented 6 months ago

Perhaps implementing and using the test suite from https://github.com/toml-lang/toml-test/ would be useful, to ensure compliance with TOML v1.0.0 (and the future v1.1.0).

TheElectronWill commented 6 months ago

Perhaps implementing and using the test suite from https://github.com/toml-lang/toml-test/ would be useful, to ensure compliance with TOML v1.0.0 (and the future v1.1.0).

Yes! That's a good idea. I've done that in #175 :)

TheElectronWill commented 6 months ago

Fixes released in v3.7.2