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

**URL:** <https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152>\
**Category:** Meta\
**Created:** [November 1, 2022, 8:50am UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152 "2022-11-01T08:50:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renari](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/renari/32/5707_2.png) [@Renari](https://discuss.gradle.org/u/Renari)\
**Post date:** [November 1, 2022, 8:50am UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152/1 "2022-11-01T08:50:57Z")

</div>

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

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

```

build.gradle

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

```

Is functionally equivalent to:  
deps.versions.toml

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

```

build.gradle

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

```

Is there something I’m missing here?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [November 1, 2022, 9:26am UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152/2 "2022-11-01T09:26:49Z")

</div>

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](https://docs.gradle.org/current/userguide/platforms.html#sub:platforms-vs-catalog)

---

<div class="post-metadata">

**Author:** ![Renari](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/renari/32/5707_2.png) [@Renari](https://discuss.gradle.org/u/Renari)\
**Post date:** [November 1, 2022, 10:14am UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152/3 "2022-11-01T10:14:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [November 1, 2022, 6:52pm UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152/4 "2022-11-01T18:52:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![soloturn](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@soloturn](https://discuss.gradle.org/u/soloturn)\
**Post date:** [July 30, 2024, 7:36am UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152/5 "2024-07-30T07:36:06Z")

</div>

@Vampire thanks for the elaboration here. i read the document - and still am not able to judge what in the case of junit should be chosen, what type do you recommend? using catalog and platform:

```gradle
testImplementation(platform(libs.junit.bom))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

```

or using catalog only, or it does not matter?

```gradle
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)

```

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [July 30, 2024, 5:16pm UTC](https://discuss.gradle.org/t/version-catalogs-vs-platforms-arent-they-the-same/44152/6 "2024-07-30T17:16:45Z")

</div>

That is not the kind of “using platform” that is meant here.

You can make a project in your build that applies the `java-platform` plugin and there define constraints (also coming from a version catalog eventually) and then make your other projects depend on that platform to control the version.

In the context here, you do not use platform, but you mix up using a 3rd-party platform vs using strings vs using version catalog entries.

I would say it should look like

```kotlin
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)

```

with the lower three not having a version in the version catalog
