gradlespring-4

Gradle: Spring 4 BOM dependencies


How to add Spring 4 BOM dependencies in Gradle configuration file?

In Maven it could be done as mentioned here.

Maven equivalent:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>${spring.framework.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<repositories>
    <repository>
        <id>spring-milestones</id>
        <url>http://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Solution

  • From https://github.com/spring-gradle-plugins/dependency-management-plugin

    plugins {
       id "io.spring.dependency-management" version "0.4.1.RELEASE"
    }
    
    dependencyManagement {
        imports {
            mavenBom 'org.springframework:spring-framework-bom:4.1.6.RELEASE'
        }
    }