Idiomatic way to use platforms with version catalogs

Hello,

I’m trying out the new version catalog feature, and I was looking for an example on how to correctly use a version catalog with one or more platforms. Specifically, I have a spring boot application which uses a platform derived from the spring boot BOM, but I also have some dependencies in a version catalog that aren’t included in the bom. Right now, my build.gradle looks like this:

dependencies {
    implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
    implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation libs.apache.velocity
    implementation libs.apache.commons.csv
    implementation 'commons-codec:commons-codec'
}

Is there a better way of handling the dependencies whose versions are derived from the platform? I tried to define type safe accessors in libs.versions.toml for the versionless dependencies, but I get an error saying that the version is required (which I guess makes sense).

The way I have it in the example does work, but it seems strange to mix and match hard coded strings and type safe accessors in that way.

1 Like