Including a dependency catalog defined in settings.gradle.kts

Is it possible to include a shared dependency catalog defined in settings.gradle.kts? I prefer to use settings.gradle.kts over libs.versions.toml because it’s more strongly typed, but I don’t seem to be able to do this:

dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {

Is there a way to achieve this, or am I forced to use .toml for shared catalogs?

You would need to build a settings plugin using the settings API and then use this settings plugin in both places where you want to have it in effect.

You can not do it like you depicted.

But anyway whereever you can use TOML, you should use TOML.
Because changing the TOML does not change and class paths, so more things can be up-to-date.
If you change one version in the settings DSL, the classpath of all build scripts changes, so all tasks are out-of-date.
I would only use the settings DSL if really needed like transforming some other representation into a version catalog or similar, but not for simple cases where TOML is sufficient.

1 Like