I am having trouble accessing a predefined version catalog in an init script. I have something like this
//init.gradle.kts
initscript {
repositories {
gradlePluginPortal()
}
}
settingsEvaluated {
dependencyResolutionManagement {
repositories {
mavenCentral()
}
versionCatalogs {
create("tpl") {
library("junit-bom", "org.junit:junit-bom:5.11.2")
}
}
}
}
allprojects {
val catalogs = extensions.getByType<VersionCatalogsExtension>()
tasks.register("some-task") {
doLast {
println("this is a test")
}
}
}
When I try to run some-task
using the init-script, I keep getting the error
Extension of type 'VersionCatalogsExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension]
Any idea why am I getting this error and what can I do resolve this?