0

I begin to use Gradle to build my Spring boot project. I want to use the new plugin block format.

May I know how to find out these correct version of each (non core) plugin.

To build a spring boot project, I need to use below 2 plugin: org.springframework.boot io.spring.dependency-management

Originally, I use the legacy plugin config. My code looks like below:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE")
    }
}

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

In above config, there is no need for me to provide the version for plugin 'io.spring.dependency-management'.

But if I use below new plugin block. My code may looks like below:

plugins {
  id 'org.springframework.boot' version '2.1.4.RELEASE'
  id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}

I have to provide version for plugin 'io.spring.dependency-management'.

My question is:

How do I know the which version of 'io.spring.dependency-management' I should use?
Which version works well or compatibility well with 'org.springframework.boot' version '2.1.4.RELEASE'?

riyaz-ali
  • 8,677
  • 2
  • 22
  • 35
Joseph Cen
  • 73
  • 6

3 Answers3

0

org.springframework.boot is currently at version 2.1.7.RELEASE;

The documentation also shows the current version number.

io.spring.dependency-management might be optional plugin:

A Gradle plugin that provides Maven-like dependency management functionality

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
0

The quickest way would be to just use Spring Initializr and pick the version values (along with "starters" and more) right from there.

You can either use the online version at start.spring.io or use curl to fetch right from your terminal.


Alternatively, you can see list of supported versions in the documentation.

To use a specific version, just apply the following -

plugins {
  id 'org.springframework.boot' version '2.1.7.RELEASE' // release as of 08-Aug-2019
}

Quoting from Spring Boot Gradle plugin documentation,

Applied in isolation the plugin makes few changes to a project. Instead, the plugin detects when certain other plugins are applied and reacts accordingly. For example, when the java plugin is applied a task for building an executable jar is automatically configured.

A typical Spring Boot project will apply the groovy, java, or org.jetbrains.kotlin.jvm plugin and the io.spring.dependency-management plugin as a minimum.

For a java project, you would do -

apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'

So, to use a specific version of Spring & Spring Boot, your build.gradle file would need a bare minimum of the following -

plugins {
  id 'java'
  id 'org.springframework.boot' version '2.1.7.RELEASE'
}
apply plugin: 'io.spring.dependency-management'

//...

Also, if you wish to use a pre-release / snapshot version, you'll need to add Spring's repositories -

pluginManagement {
  repositories {
    maven { url 'https://repo.spring.io/milestone' }
    gradlePluginPortal()
  }
  resolutionStrategy {
    eachPlugin {
      if (requested.id.id == 'org.springframework.boot') {
        useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
      }
    }
  }
}

If you use the Spring Initializr all this is handled for you!

Community
  • 1
  • 1
riyaz-ali
  • 8,677
  • 2
  • 22
  • 35
0

I am still using SpringBoot 1.5.x these days, and I found that when apply 'org.springframework.boot' plugin the dependency-management plugin will apply automatically with compatible version.

Screenshot of corresponding codes lists below : enter image description here

Rong.l
  • 338
  • 2
  • 13