Migrate spring-retry RetryPolicy construction to Spring Framework 7 RetryPolicy.builder()
io.moderne.java.spring.boot4.MigrateSpringRetryPolicyToRetryPolicyBuilderArtifactio.moderne.recipe:rewrite-springRewrite construction of spring-retry policies at a local variable declaration into the equivalent org.springframework.core.retry.RetryPolicy.builder() chain from Spring Framework 7, and retype the local to SF7 RetryPolicy. Supported inputs: SimpleRetryPolicy (all four ctor overloads, with traverseCauses ignored and the classifier Map.of(...) bucketed into .includes(...)/.excludes(...)), MaxAttemptsRetryPolicy (default 3 attempts or explicit int), NeverRetryPolicy (zero retries), and TimeoutRetryPolicy (default 1000ms or explicit long ms, wrapped in Duration.ofMillis(...) for SF7). Trailing setter chains (setMaxAttempts on SimpleRetryPolicy/MaxAttemptsRetryPolicy, setTimeout on TimeoutRetryPolicy) are folded into the builder chain and the setter statements deleted; a setter overrides the corresponding constructor-time builder call. The maxAttempts argument is decremented by one to match SF7's maxRetries semantics. The migration is skipped when the local is reassigned, when any setter in the chain is unmappable, when the classifier is not an inline Map.of(...) literal with class-literal keys and boolean-literal values, or when the declaration has multiple named variables.
Add to your build
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("io.moderne.java.spring.boot4.MigrateSpringRetryPolicyToRetryPolicyBuilder")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("io.moderne.recipe:rewrite-spring:0.44.0")
}
Then run
./gradlew rewriteRunUsage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe io.moderne.java.spring.boot4.MigrateSpringRetryPolicyToRetryPolicyBuilderIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-spring:RELEASEData tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats