# Use of versionCatalogs in settings plugin

**URL:** <https://discuss.gradle.org/t/use-of-versioncatalogs-in-settings-plugin/48586>\
**Category:** Help/Discuss\
**Created:** [May 30, 2024, 9:14am UTC](https://discuss.gradle.org/t/use-of-versioncatalogs-in-settings-plugin/48586 "2024-05-30T09:14:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flemminglundahl](https://avatars.discourse-cdn.com/v4/letter/f/9f8e36/32.png) [@flemminglundahl](https://discuss.gradle.org/u/flemminglundahl)\
**Post date:** [May 30, 2024, 9:14am UTC](https://discuss.gradle.org/t/use-of-versioncatalogs-in-settings-plugin/48586/1 "2024-05-30T09:14:21Z")

</div>

Hello there

I am currently using a script file to setup my dependencyResolutionManagement in mulitple projects. I would like to change this to a plugin, but I am having some issues using my TOML file the same way in the plugin as I do in the script file.

I load my libs.version.toml file as such.

```gradle
dependencyResolutionManagement {
      versionCatalogs {
        create("libs") {
          from(files("libs.versions.toml"))
        }
    }
}

```

And apply it where needed with

```gradle
apply(from = "$gradleFolder/dependencyResolutionManagement.gradle.kts")

```

But it seems that I do not have the same apis when running from a plugin, which I think is odd, since it to my understanding would run in the same context.

I denfine it as such in my plugin.

```gradle
  override fun apply(settings: Settings) {
    settings.dependencyResolutionManagement {
      versionCatalogs {
        create("libs") {
          from(files("libs.versions.toml"))
        }
      }
    }
  }

```

But files() is not available here. I trace it back to a part of the project, which ofcourse isn’t created yet at this time (don’t understand how it is different as a script file).

If I remove the files() wrapper I get a IllegalDependencyNotation exception.

What is the correct way of doing this as plugin?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 31, 2024, 1:57am UTC](https://discuss.gradle.org/t/use-of-versioncatalogs-in-settings-plugin/48586/2 "2024-05-31T01:57:14Z")

</div>

From the top of my head, what you need is `settings.layout.settingsDirectory.files("libs.versions.toml")`

---

<div class="post-metadata">

**Author:** ![flemminglundahl](https://avatars.discourse-cdn.com/v4/letter/f/9f8e36/32.png) [@flemminglundahl](https://discuss.gradle.org/u/flemminglundahl)\
**Post date:** [May 31, 2024, 7:27am UTC](https://discuss.gradle.org/t/use-of-versioncatalogs-in-settings-plugin/48586/3 "2024-05-31T07:27:53Z")

</div>

That did it. Thank you very much!
