I am confused about publishing version catalogs. T...
# community-support
c
I am confused about publishing version catalogs. The preliminary example given has. I am kind of assuming that we only need to use the
catalog {...]
for publishing one?
Copy code
catalog {
    // declare the aliases, bundles and versions in this block
    versionCatalog {
        library("my-lib", "com.mycompany:mylib:1.2")
    }
}
but then says we "The catalog must be created programmatically, see Programming catalogs for details." which uses the format
Copy code
dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            version("groovy", "3.0.5")
            version("checkstyle", "8.37")
            library("groovy-core", "org.codehaus.groovy", "groovy").versionRef("groovy")
            library("groovy-json", "org.codehaus.groovy", "groovy-json").versionRef("groovy")
            library("groovy-nio", "org.codehaus.groovy", "groovy-nio").versionRef("groovy")
            library("commons-lang3", "org.apache.commons", "commons-lang3").version {
                strictly("[3.8, 4.0[")
                prefer("3.9")
            }
        }
    }
}
p
The first one is about creating a version catalog for publishing, the second one is creating a local version catalog for your build via the api instead of using toml or a published catalog.
Don’t forget the add the catalog components if you want to publish it: publishing { publications { create<MavenPublication>("maven") { from(components["versionCatalog"]) } } }
👍 1