ursus
01/16/2025, 6:16 PMimplementation "org.jetbrains.kotlin:kotlin-reflect"
and it works fine
Does it pick up the kotlin version from the applied kotlin gradle plugin?
Or is that shorthand for latest?tapchicoma
01/16/2025, 6:46 PMDoes it pick up the kotlin version from the applied kotlin gradle plugin?Yes
ursus
01/16/2025, 6:47 PMursus
01/16/2025, 6:53 PMruntimeOnly "org.postgresql:postgresql"
which is also version-less & I presume its not kotlin jvm plugin that adds that and I can only guess it's one of the spring plugins .. but a guess nonethelessVampire
01/16/2025, 10:55 PMplatform(...)
.
Besides that, Gradle has to know a version for a dependency. If you have a dependency twice in the tree with different versions (by default) the higher version is used. If you have it twice once with and once without version, the version wins. You can also have version constraints for libraries, which means it is no dependency, but if you add that dependency the version of the constraint is also used. If you use a BOM / platform this adds all the contained things as version constraints. (the Spring dependency management plugin does something similar, just in a bad way and some other bad things)
So if you have a dependency with its version already, or a version constraint for that dependency, or a platform / BOM which contains it and thus a version constraint, you can use the dependency without version as it just uses the version already known. And if there is no such version you get an error.
Using the latest version would be +
as version or latest.release
or latest.integration
, depending on exact intended semantic.ursus
01/16/2025, 11:12 PMVampire
01/16/2025, 11:55 PMursus
01/16/2025, 11:58 PM[versions]
kotlin = "2.1.0"
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
kotlin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" }
spring-boot = { id = "org.springframework.boot", version = "3.4.1" }
spring-dependency-management = { id = "io.spring.dependency-management", version = "1.1.7" }
[libraries]
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" }
postgres = { module = "org.postgresql:postgresql" }
spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web" }
spring-boot-starter-data-jpa = { module = "org.springframework.boot:spring-boot-starter-data-jpa" }
spring-boot-openapi = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", version = "2.7.0" }
plugins {
alias libs.plugins.kotlin.jvm
alias libs.plugins.kotlin.spring
alias libs.plugins.kotlin.jpa
alias libs.plugins.spring.boot
alias libs.plugins.spring.dependency.management
}
dependencies {
implementation libs.kotlin.reflect
implementation libs.spring.boot.starter.web
implementation libs.spring.boot.starter.data.jpa
implementation libs.spring.boot.openapi
runtimeOnly libs.postgres
}
just most basic setupursus
01/17/2025, 12:03 AM[versions]
kotlin = "2.1.0"
spring = "3.4.1"
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
kotlin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" }
spring-boot = { id = "org.springframework.boot", version.ref = "spring" }
[libraries]
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" }
postgres = { module = "org.postgresql:postgresql", version = "42.7.5" }
spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "spring" }
spring-boot-starter-data-jpa = { module = "org.springframework.boot:spring-boot-starter-data-jpa", version.ref = "spring" }
spring-boot-openapi = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", version = "2.7.0" }
I mean I can obviously do this (and remove the dependency managemenet plugin), but should I? is there a bom for spring at all?Vampire
01/17/2025, 12:04 AMursus
01/17/2025, 12:05 AMIt is coming from a plugin you should stop using.sounds like it 😄
Vampire
01/17/2025, 12:06 AMursus
01/17/2025, 12:08 AMVampire
01/17/2025, 12:09 AMursus
01/17/2025, 12:10 AMVampire
01/17/2025, 12:10 AMVampire
01/17/2025, 12:10 AMursus
01/17/2025, 12:12 AMplugins {
id 'java'
id 'org.springframework.boot' version '3.4.1'
}
apply plugin: 'io.spring.dependency-management'
this is the good version?Vampire
01/17/2025, 12:13 AMursus
01/17/2025, 12:13 AMBelow the bad version they show the good version.
Vampire
01/17/2025, 12:13 AMursus
01/17/2025, 12:13 AMursus
01/17/2025, 12:15 AMversion.ref
in catalogue?
I mean I can never tell what's inside the bomursus
01/17/2025, 12:16 AMimplementation platform..
it if it is necessary & there's a spring boot gradle plugin .. why won't the plugin simply add it
I'm new to bomsVampire
01/17/2025, 12:20 AMI mean I can never tell what's inside the bomSure you can, you can just read it.
is using a bom preferred over the sharedBut again, whether you specify versions yourself or use the BOM is up to you. Iirc the sense of Spring Boot and the BOM is that they say "these versions properly work together we recommend you use those". Whether you follow that recommendation is up to you. Besides that you cannot use a "shared `version.ref`" except for the Spring-own modules. It defines versions for dozens of other dependencies and those are all different.in catalogue?version.ref
also, not sure why do I need toTo use their BOM and thus the versions of the dependencies they recommend as "working together properly"implementation platform..
it if it is necessaryIf you want to use their version recommendations, yes
there's a spring boot gradle plugin .. why won't the plugin simply add itI don't know, ask them. Probably for the same reason they also have in the getting started docs and generator the Spring Dependency Management plugin. Why that is the case is a miracle to me when even the maintainer of the plugin tells to not use it anymore. Maybe it is due to legacy or backwards compatibility reasons. 🤷♂️
Vampire
01/17/2025, 12:21 AMursus
01/17/2025, 12:22 AMspring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "spring" }
spring-boot-starter-data-jpa = { module = "org.springframework.boot:spring-boot-starter-data-jpa", version.ref = "spring" }
version.ref = spring
anywaysVampire
01/17/2025, 12:23 AMursus
01/17/2025, 12:23 AMimplementation platform..
doesnt actually include any dependency, just a sort of map of version to use if said dependency were to be included?Vampire
01/17/2025, 12:24 AMursus
01/17/2025, 12:26 AMfoundation:2.0
and a 3rd party dependency depends on foundation:2.1
directly, then I'll get the 2.1
anyways, correct?Vampire
01/17/2025, 12:27 AMursus
01/17/2025, 12:28 AMursus
01/17/2025, 12:29 AMversion.ref
if that needs to be multiple numbers for some reason, gotcha
but still I'd like to see what's in it, so I can say remove the exact versions, now I just guess & compile/hopeVampire
01/17/2025, 12:30 AMVampire
01/17/2025, 12:31 AMbut still I'd like to see what's in it, so I can say remove the exact versionsIt's a text file, read it
ursus
01/17/2025, 12:31 AMVampire
01/17/2025, 12:31 AMVampire
01/17/2025, 12:31 AMdependencies
output or a build --scan
Vampire
01/17/2025, 12:32 AMVampire
01/17/2025, 12:32 AMursus
01/17/2025, 12:34 AMVampire
01/17/2025, 12:34 AMVampire
01/17/2025, 12:34 AMursus
01/17/2025, 12:35 AMVampire
01/17/2025, 12:35 AMVampire
01/17/2025, 12:35 AMursus
01/17/2025, 12:35 AMursus
01/17/2025, 12:35 AMVampire
01/17/2025, 12:35 AMVampire
01/17/2025, 12:38 AMursus
01/17/2025, 12:40 AMVampire
01/17/2025, 12:42 AMVampire
01/17/2025, 12:43 AMVampire
01/17/2025, 12:43 AMVampire
01/17/2025, 12:43 AMursus
01/17/2025, 12:44 AMursus
01/17/2025, 12:45 AMVampire
01/17/2025, 12:45 AMVampire
01/17/2025, 12:46 AMVampire
01/17/2025, 12:46 AMursus
01/17/2025, 12:46 AMVampire
01/17/2025, 12:46 AMVampire
01/17/2025, 12:47 AMVampire
01/17/2025, 12:47 AMVampire
01/17/2025, 12:49 AMVampire
01/17/2025, 12:49 AMursus
01/17/2025, 12:51 AMunrelated
in terms of gradle dependencies?
anyways what I meant was if the bom is just a "collection of stuff you might probably be using" & I should obey it, in that sense that bom is master of the versions of the given stuffVampire
01/17/2025, 12:54 AMVampire
01/17/2025, 12:54 AMursus
01/17/2025, 12:58 AMVampire
01/17/2025, 1:00 AMVampire
01/17/2025, 1:01 AMVampire
01/17/2025, 1:01 AMursus
01/17/2025, 1:02 AMVampire
01/17/2025, 1:02 AMursus
01/17/2025, 1:03 AMVampire
01/17/2025, 1:04 AMVampire
01/17/2025, 1:04 AMVampire
01/17/2025, 1:05 AMVampire
01/17/2025, 1:05 AMursus
01/17/2025, 1:07 AM<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
ursus
01/17/2025, 1:08 AMVampire
01/17/2025, 1:09 AMVampire
01/17/2025, 1:10 AMVampire
01/17/2025, 1:10 AMVampire
01/17/2025, 1:11 AM<dependency>
tag is not within a <dependencies>
tag.
It is within a <dependencyManagement>
tag.
That means it is a version constraint and thus part of the BOM.ursus
01/17/2025, 1:11 AMVampire
01/17/2025, 1:11 AMVampire
01/17/2025, 1:12 AMVampire
01/17/2025, 1:12 AMursus
01/17/2025, 1:12 AMVampire
01/17/2025, 1:13 AMVampire
01/17/2025, 1:13 AMVampire
01/17/2025, 1:14 AMursus
01/17/2025, 1:15 AMVampire
01/17/2025, 1:18 AMso why is this necessary (to mention jackson in the bom at all)Who says you are using spring-boot-starter at all?
Vampire
01/17/2025, 1:19 AMVampire
01/17/2025, 1:20 AMVampire
01/17/2025, 1:20 AMjackson-a
version 1 with jackson-b
version 2, but either all version 1 or all version 2.
The Spring Boot BOM is just for a different use-case that I described above.ursus
01/17/2025, 1:21 AMursus
01/17/2025, 1:22 AMursus
01/17/2025, 1:22 AMVampire
01/17/2025, 1:25 AMVampire
01/17/2025, 1:26 AMVampire
01/17/2025, 1:27 AMVampire
01/17/2025, 1:27 AMVampire
01/17/2025, 1:28 AMplatform(...)
you do the same, just in a technically better way and without the other non-sense that plugin is doing.