Skip to content

Discontinue used of io.spring.dependency-management, use Gradle's BOM support instead #21723

Closed
@candrews

Description

@candrews

The io.spring.dependency-management Gradle plugin performs dependency management, specifically with regards to BOM importing. Gradle 5.0 added BOM importing. Spring Boot requires Gradle 5.6 or later. Therefore, I think Spring Boot's documentation and Spring Initializr should be updated to use Gradle's built in functionality and stop recommending the use of the io.spring.dependency-management plugin.

Here's an example build.gradle from Initializr today:

plugins {
	id 'org.springframework.boot' version '2.3.0.RELEASE'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
}

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

repositories {
	mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
}

test {
	useJUnitPlatform()
}

I recommend it be changed to look like this:

plugins {
	id 'org.springframework.boot' version '2.3.0.RELEASE'
	id 'java'
}

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

repositories {
	bom
	annotationProcessor {
		extendsFrom bom
	}
	implementation {
		extendsFrom bom
	}
	mavenCentral()
}

dependencies {
	bom platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
}

test {
	useJUnitPlatform()
}

and Spring Boot documentation updated as well.

Relevant Stack Overflow discussion

Advantages of this change include:

  • No more need to dedicate resources to the io.spring.dependency-management project
  • Closer to standard/typical Gradle builds, reducing the learning curve for users

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions