Version catalogs vs platforms, aren't they the same?

Recently I’ve been looking into platforms and it seems to me they’re the same as version catalogs, the only difference from what I can tell is semantics.

e.g.
platform

plugins {
  `java-platform`
}
dependencies {
  constraints {
    api("my.dependency:dependency:1.2.3")
  }
}

build.gradle

plugins {
  `java-library`
}
dependencies {
  implementation(platform(project(":platform"))
  implementation("my.dependency:dependency")
}

Is functionally equivalent to:
deps.versions.toml

[libs]
dependency = { module = "my.dependency:dependency", version = "1.2.3" }

build.gradle

plugins {
  `java-library`
}
dependencies {
  implementation(deps.libs.dependency)
}

Is there something I’m missing here?

They are not at all the same, though they are related. You can even use both together. But it is all detailed in the documentation at Sharing dependency versions between projects

1 Like

Ah, thanks for that, I didn’t know you could publish platforms and consume them in multiple projects.

That’s actually not a difference.
You can publish platforms as well as version catalogs and consume both in multiple projects.

1 Like