spring-io / start.spring.io

https://start.spring.io
Apache License 2.0
2.22k stars 902 forks source link

Add Gradle Versions Catalog with libs.versions.toml file #1600

Open hantsy opened 1 day ago

hantsy commented 1 day ago

Centralize the dependencies and versions in the gradle/libs.versions.toml, and it also can be recognized by Github dependenta, etc.

See: https://docs.gradle.org/current/userguide/platforms.html

bclozel commented 1 day ago

I'm not sure there are a lot of benefits in doing this. Also see this discussion in Spring Boot: https://github.com/spring-projects/spring-boot/issues/29588

hantsy commented 14 hours ago

@bclozel This issue could be under project https://github.com/spring-io/initializr, what I want it the generated gradle project from start.spring.io using gradle/libs.versions.toml to manage the dependencies and versions in a central place.

wilkinsona commented 7 hours ago

Like @bclozel, I don't think this should be addressed here (or in https://github.com/spring-io/initializr).

For this to be beneficial, we'd have to extract the versions that are currently published in spring-boot-dependencies and create a version catalog from them. That's a significant amount of work. If it's going to be done anywhere, it should be done in Spring Boot which is what https://github.com/spring-projects/spring-boot/issues/29588 is already tracking.

mhalbritter commented 5 hours ago

Most of the dependencies are managed by Spring Boots spring-boot-dependencies, so there are not a lot of version numbers in a typical build.gradle file generated by start.spring.io. For example, I generated a "typical" application and the build file looks like this:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.3.4'
    id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(23)
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
    runtimeOnly 'org.postgresql:postgresql'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
    useJUnitPlatform()
}

The only versions in here are the two plugins, and I'm not sure you can use the version catalog for them.

There are a few dependencies on start.spring.io which are not managed by spring-boot-dependencies, but I don't think there's much value in creating a versions catalog for them.

However, if Spring Boot provides a version catalog in the future, start.spring.io will use it.

mhalbritter commented 5 hours ago

Given there are not many versions in the build file, what's your need for the version catalog @hantsy ?