添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Skip to main content

Add io.spring.dependency-management plugin, if in use

org.openrewrite.gradle.spring.AddSpringDependencyManagementPlugin

Prior to Spring Boot 2.0 the dependency management plugin was applied automatically as part of the overall spring boot plugin. Afterwards the dependency-management plugin must be applied explicitly, or Gradle's platform() feature may be used instead. This recipe makes usage of io-spring.dependency-management explicit in anticipation of upgrade to Spring Boot 2.0 or later.

Recipe source

GitHub , Issue Tracker , Maven Central

This recipe is available under the Moderne Source Available License .

Example

Before
build.gradle
plugins {
id "java"
id "org.springframework.boot" version "1.5.22.RELEASE"
}
repositories {
mavenCentral()
}
dependencyManagement { }
dependencies {
compile "org.springframework.boot:spring-boot-starter-web"
}
After
build.gradle
plugins {
id "java"
id "org.springframework.boot" version "1.5.22.RELEASE"
id "io.spring.dependency-management" version "1.0.6.RELEASE"
}
repositories {
mavenCentral()
}
dependencyManagement { }
dependencies {
compile "org.springframework.boot:spring-boot-starter-web"
}

Usage

This recipe has no required configuration options. It can be activated by adding a dependency on org.openrewrite.recipe:rewrite-spring in your build file or by running a shell command (in which case no build changes are needed):

  1. Add the following to your build.gradle file:
build.gradle
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}

rewrite {
activeRecipe("org.openrewrite.gradle.spring.AddSpringDependencyManagementPlugin")
setExportDatatables(true)
}

repositories {
mavenCentral()
}

dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:6.9.0")
}
  1. Run gradle rewriteRun to run the recipe.
  2. Create a file named init.gradle in the root of your project.
init.gradle
initscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies { classpath("org.openrewrite:plugin:7.9.0") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:6.9.0")
}
rewrite {
activeRecipe("org.openrewrite.gradle.spring.AddSpringDependencyManagementPlugin")
setExportDatatables(true)
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
}
  1. Run the recipe.
shell
gradle --init-script init.gradle rewriteRun

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.