Use external toml which version is in project toml

I’d like to use external toml, but its version is in project toml and it is not accessible when loading external toml in settings:

  val  externalTomlVersion = ?
    versionCatalogs {
        create("extraLibs") {
externalTomlVersion = "2022.04.9"

I tried to use
but got error:
Extension of type ‘VersionCatalogsExtension’ does not exist. Currently registered extension types: [ExtraPropertiesExtension]

I don’t think you can do it, except by parsing the TOML file yourself.
The settings script defines the version catalog, so it cannot use it yet, one of the typical hen and egg problems.

If I can parse it by myself then why not to publish an API to use it properly?
I hope that there should be an offiсial way to do it :slight_smile:

As I said, hen and egg.
Settings script provides version catalogs, from applied settings plugins, from DSL in the settings script, from the default TOML file, …
So a proper API cannot be provided as the version catalogs are simply not yet established at that time.
But if you have it in a file and you know that, there is nothing stopping you to process that file.

I also tried to parse it via internal API, but got error

val libs = Toml.parse(File(rootProject.projectDir.absoluteFile, "gradle/libs.versions.toml").toPath())
java.lang.NoClassDefFoundError: org/gradle/internal/impldep/org/tomlj/Toml
        at Settings_gradle.<init>(settings.gradle.kts:52)

Well, don’t use internal API, but e. g. use tomlj directly?

I’ve added dependency and it works

buildscript {

    repositories {
        maven {
    dependencies {
val libs = Toml.parse(File(rootProject.projectDir.absoluteFile, "gradle/libs.versions.toml").toPath())
val externalVersion = libs.getString("versions.external")