Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
43599d6
build: add OpenRewrite recipes for the Boot 2.7 -> 3.5 migration
Oct 20, 2026
4b16eee
build: narrow the Boot 2 -> 3 OpenRewrite recipe to the parts the dry…
Oct 20, 2026
d064a45
docs: add Boot 2.7 -> 4.0 migration plan
Oct 20, 2026
a10431e
docs: record the six migration decisions in the plan
Oct 20, 2026
0405876
docs: stack the migration PRs and release at Boot 3.5
Nov 2, 2026
5a4a0cb
test: run Flyway migrations and the ApiReview mapping on Postgres 13
Nov 2, 2026
2c21d6e
test: cover the production security configuration
Nov 2, 2026
9a418e8
test: record a golden master of the HTTP surface
Nov 2, 2026
322bc7e
test: migrate the last JUnit 4 test, drop vintage engine, close cover…
Nov 2, 2026
5a5d7b4
build: Gradle 8.0-rc-1 -> 8.14.6
Nov 2, 2026
08e1e9d
build: Kotlin 1.8.0 -> 2.2.21 and Dokka 1.7 -> 2.2
Nov 2, 2026
4b6626e
build: spotless 6.12.1 -> 7.2.1, ktlint 0.47.1 -> 1.7.1
Nov 2, 2026
a280692
style: reformat with ktlint 1.7.1 (formatting only)
Nov 2, 2026
e5a11f9
chore: add .git-blame-ignore-revs for the ktlint reformat
Nov 2, 2026
0c30cda
docs: record the stage 2 result and the pinned versions audit
Nov 2, 2026
a8916a5
build: apply the OpenRewrite Boot 3.5 recipe (plugin 3.5.16, jakarta,…
Nov 3, 2026
4a78234
feat: Hibernate 6, Spring Boot managed dependencies and config cleanup
Nov 3, 2026
d986da1
feat: Spring Security 6, own problem+json handler and schema controll…
Nov 3, 2026
597b3ca
docs: record the stage 3 result and the behaviour differences
Nov 3, 2026
193f3be
fix: address the stage 3 review findings
Nov 3, 2026
d8abce0
fix: constrain swagger-parser-v3 to 2.1.22 (snakeyaml 2)
Nov 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Formatting-only: ktlint 0.47.1 -> 1.7.1 reformat
a280692a165d859951319b462a11604404bb6d02
3 changes: 2 additions & 1 deletion .github/workflows/build-zally.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# boot4/** : stacked PRs of the Spring Boot migration target the previous stage's branch, not main
branches: [ main, 'boot4/**' ]

jobs:
build-zally:
Expand Down
3 changes: 2 additions & 1 deletion server/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ insert_final_newline=true
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=off
disabled_rules=import-ordering
# ktlint 0.x used `disabled_rules=import-ordering`; 1.x configures each rule on its own
ktlint_standard_import-ordering=disabled
266 changes: 266 additions & 0 deletions server/BOOT4_MIGRATION_PLAN.md

Large diffs are not rendered by default.

60 changes: 37 additions & 23 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

java {
Expand All @@ -7,7 +8,7 @@ java {
}

plugins {
val kotlinVersion = "1.8.0"
val kotlinVersion = "2.2.21"
val klintVersion = "11.0.0"

// The buildscript is also kotlin, so we apply at the root level
Expand All @@ -21,9 +22,10 @@ plugins {
signing
eclipse

id("org.jetbrains.dokka") version "1.7.20" apply false
id("org.jetbrains.dokka") version "2.2.0" apply false
id("org.jetbrains.dokka-javadoc") version "2.2.0" apply false
id("com.github.ben-manes.versions") version "0.44.0"
id("com.diffplug.spotless") version "6.12.1"
id("com.diffplug.spotless") version "7.2.1"
}

allprojects {
Expand All @@ -32,6 +34,13 @@ allprojects {
}
}

/**
* The published library modules. They have no Spring Boot BOM, so they pin their own Jackson and snakeyaml, and keep
* an older Kotlin language level. Every other module is an application managed by Spring Boot: an explicit version
* there would override the Boot-managed one, so a new module gets no pins unless it is listed here.
*/
val publishedLibraries = setOf("zally-core", "zally-rule-api", "zally-ruleset-zalando", "zally-ruleset-zally", "zally-test")

subprojects {
group = "org.zalando"

Expand All @@ -40,6 +49,7 @@ subprojects {
apply(plugin = "com.github.ben-manes.versions")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jetbrains.dokka-javadoc")
apply(plugin = "maven-publish")
apply(plugin = "jacoco")
apply(plugin = "signing")
Expand All @@ -49,18 +59,23 @@ subprojects {
includeCompileClasspath = false
}

tasks.withType<KotlinCompile>().configureEach() {
kotlinOptions.jvmTarget = "17"
}

tasks.withType<DokkaTask>().configureEach {
outputDirectory.set(buildDir.resolve("dokka"))
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
// The library modules are published: keep the language and API level they were released with, so that
// consumers on an older Kotlin compiler can still read their metadata.
if (project.name in publishedLibraries) {
languageVersion.set(KotlinVersion.KOTLIN_1_8)
apiVersion.set(KotlinVersion.KOTLIN_1_8)
}
}
}

tasks.register("javadocJar", Jar::class) {
dependsOn(tasks["dokkaJavadoc"])
val javadoc = tasks.named("dokkaGeneratePublicationJavadoc")
dependsOn(javadoc)
archiveClassifier.set("javadoc")
from(tasks["dokkaJavadoc"])
from(javadoc)
}

tasks.register("sourcesJar", Jar::class) {
Expand Down Expand Up @@ -155,17 +170,16 @@ subprojects {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlin:kotlin-reflect")

// We define this here so all subprojects use the same version of jackson
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.1")
implementation("com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.1")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.1")
implementation("org.yaml:snakeyaml:1.33")
if (project.name in publishedLibraries) {
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.1")
implementation("com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.1")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.1")
implementation("org.yaml:snakeyaml:1.33")
}

testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.9.1")
testImplementation("com.jayway.jsonpath:json-path-assert:2.7.0")
testImplementation("org.mockito:mockito-core:4.11.0")
}

jacoco {
Expand All @@ -175,11 +189,11 @@ subprojects {
spotless {
kotlin {
target("**/*.kt")
ktlint("0.47.1")
ktlint("1.7.1")
}
kotlinGradle {
target("**/*.gradle.kts", "*.gradle.kts")
ktlint("0.47.1")
ktlint("1.7.1")
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
87 changes: 87 additions & 0 deletions server/openrewrite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# OpenRewrite recipes for the Boot 2.7 -> 3.5 migration

Companion to the `spring-boot4-migration` skill, which starts at Boot 3.5. These cover the part before it:
Boot 2.7 -> 3.5. Nothing here modifies `build.gradle.kts`: the plugin is injected with an init script, so there
is nothing to clean up afterwards.

**Status**

| Recipe | Dry run | Result |
|--------|---------|--------|
| `Step3_UpgradeTo35` | done, applied in stage 3 | 6 files; one value wrong (`access.default: read-only`, must be `unrestricted`), fixed by hand |
| `Step1_Junit5` | blocked, not run | unknown. `NullPointerExceptionTest` uses `SpringClassRule`/`SpringMethodRule`/`@Rule` in Kotlin and the Java-oriented recipe may skip it. |
| `Step2_Tooling` | blocked, not run | unknown. The Kotlin version is a text replace of `val kotlinVersion = "1.8.0"` in the two build files. |
| `Step3b_RemoveLegacyLibraries` | not run | untested |

### Why `Step3_UpgradeTo35` is a hand-picked subset

The first version used the official composite `org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_5`.
Its dry run on Zally (17 files) was mostly harmful:

- `ApiReview.kt`: wrote Java syntax `PersistentOffsetDateTime.class` into Kotlin (does not compile).
- `NoSecurityConfiguration.kt`: `override fun filterChain(...)` on a `WebSecurityConfigurerAdapter` that has no such
method, `antMatchers` left in place. `OAuthConfiguration.kt`: half-converted to lambdas, still using
`.requestMatchers().antMatchers().and()`, `.access("#oauth2...")` and the removed adapter. Both need a manual rewrite.
- `zally-rule-api`: replaced `swagger-models` with `swagger-models-jakarta` twice (2.2.7 and 2.2.55) and dropped
`io.swagger:swagger-models:1.6.9`, although `io.swagger.models.Swagger` is still imported 5 times.
- `runtimeOnly("javax.xml.bind:jaxb-api:2.3.1")` added to 8 build files, including `buildSrc`, and a spurious
`jakarta.annotation-api` in `zally-core`.
- `hibernate-core` pinned to an explicit `6.5.3.Final`, which would hold back Boot's managed version.
- Flyway was not touched (`flyway-core:9.11.0` is pinned) and `junit-vintage-engine` was removed while
`NullPointerExceptionTest` still imports `org.junit.Rule`.

The useful parts are kept as explicit steps: Boot plugin version, `javax.persistence`/`javax.servlet` ->
`jakarta.*`, and the property migrations (`spring.profiles` -> `spring.config.activate.on-profile`,
`management.endpoints.enabled-by-default` -> `access.default`). `init.gradle` excludes the library modules and
`buildSrc`, which have no Spring dependency. The Boot version is a text replace instead of
`UpgradePluginVersion` because that recipe also rewrites `hibernate-core` to the old managed version.

Expected saving: roughly the Jakarta imports, the Boot version and two property keys. The security, Hibernate,
Flyway and test rewrites are manual in any case (list below).

Dead legacy keys in `application-dev.yml` / `application-test.yml` (`endpoints.*`, `security.basic.enabled`)
are not handled: delete them by hand.


## Usage

JDK 17 is required (Kotlin 1.8 does not know JDK 21). From `server/`:

```bash
# 1. preview, writes build/reports/rewrite/rewrite.patch and changes no source file
./gradlew --init-script openrewrite/init.gradle rewriteDryRun \
-Drewrite.activeRecipe=org.zalando.zally.migration.Boot2.Step1_Junit5

# 2. apply
./gradlew --init-script openrewrite/init.gradle rewriteRun \
-Drewrite.activeRecipe=org.zalando.zally.migration.Boot2.Step1_Junit5
```

Then review `git diff`, run `./gradlew build`, commit, and continue with the next recipe.

## Recipes (run in this order, one commit each)

| # | Recipe | What it does | Still manual afterwards |
|---|--------|--------------|-------------------------|
| 1 | `Step1_Junit5` | JUnit 4 -> 5 (SpringRunner, rules). Runs on Boot 2.7. | Verify `NullPointerExceptionTest` and `RestApiTestConfiguration`; drop `junit-vintage-engine`. |
| 2 | `Step2_Tooling` | Gradle wrapper -> 8.14.x, Kotlin plugins -> 2.2.x. | Dokka 2.x (`dokkaJavadoc` task is gone), ktlint/Spotless, kapt, pinned versions in the root `build.gradle.kts`. |
| 3 | `Step3_UpgradeTo35` | Boot plugin 3.5.16, javax -> jakarta (persistence, servlet), property renames. | See the "Manual work" list below. |
| 3b | `Step3b_RemoveLegacyLibraries` | Removes `stups-spring-oauth2-server`, `twintip-spring-web`, `problem-spring-web`, `usertype.core`. Opt-in: compilation fails on purpose. | Write the replacements. |

Pinned tool versions (`7.39.0` plugin, `rewrite-spring 6.31.0`) match the `spring-boot4-migration` skill.
Newer releases exist (plugin 7.41.0, rewrite-spring 6.37.1); bump them together with the skill.

## Manual work OpenRewrite will not do for Zally

- `OAuthConfiguration` / `NoSecurityConfiguration`: rewrite to `SecurityFilterChain` with the built-in resource
server and a tokeninfo `OpaqueTokenIntrospector`. The legacy `#oauth2.hasScope('uid')` expression has no recipe.
- `ApiReview.kt`: `@Type(PersistentOffsetDateTime)` -> native `OffsetDateTime` mapping with UTC storage. The
`created` column is `TIMESTAMP WITHOUT TIME ZONE` and `ddl-auto` is `validate`, so check the mapping.
- `ApiReviewRepository` HQL: `isSuccessfulProcessed = 'True'`, and the unqualified column names `day` and
`user_agent` are rejected or behave differently under Hibernate 6.
- `WebMvcConfiguration`: `favorPathExtension(true)` (`.yaml` suffix negotiation) and trailing-slash URLs
(`/health/`, `/api-violations/`). Spring 6 stops matching trailing slashes by default.
- Replace `twintip` (2 classes, `javax.servlet`) with a small controller serving `/api`.
- `application*.yml`: `spring.profiles: local`, `endpoints.*`, `security.basic.enabled`, `non_contextual_creation`.
- Pinned versions in `build.gradle.kts` (Jackson 2.14.1, snakeyaml 1.33, mockito, logback, junit 5.9.1, flyway
9.11.0): explicit versions beat Boot's dependency management, so these silently hold the stack back.
40 changes: 40 additions & 0 deletions server/openrewrite/init.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// OpenRewrite init script: applies the rewrite plugin to the build WITHOUT touching any build.gradle.kts,
// so there is nothing to clean up afterwards (the Boot 3 -> 4 skill's Phase 4 needs a cleanup step for this).
//
// ./gradlew --init-script openrewrite/init.gradle rewriteDryRun -Drewrite.activeRecipe=<recipe>
// ./gradlew --init-script openrewrite/init.gradle rewriteRun -Drewrite.activeRecipe=<recipe>
//
// Recipes are defined in openrewrite/rewrite.yml, see openrewrite/README.md.
// Versions match the ones pinned by the spring-boot4-migration skill.
initscript {
repositories {
maven { url = uri("https://plugins.gradle.org/m2") }
}
dependencies {
classpath("org.openrewrite:plugin:7.39.0")
}
}

rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)

dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:6.31.0")
}

rewrite {
configFile = new File(rootProject.projectDir, "openrewrite/rewrite.yml")
// Library modules and buildSrc have no Spring dependency. The Jakarta/jaxb/swagger recipes
// only do harm there (see README.md).
exclusion("**/zally-core/**", "**/zally-rule-api/**", "**/zally-ruleset-zalando/**",
"**/zally-ruleset-zally/**", "**/zally-test/**", "**/buildSrc/**")
}

afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
}
85 changes: 85 additions & 0 deletions server/openrewrite/rewrite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# OpenRewrite recipes for the Zally Spring Boot 2.7 -> 3.5 migration.
# Run them one at a time, in order, and commit after each (see README.md).
---
type: specs.openrewrite.org/v1beta/recipe
name: org.zalando.zally.migration.Boot2.Step1_Junit5
displayName: Zally Boot 2 migration, step 1 - JUnit 4 to JUnit 5 (still on Boot 2.7)
description: >
Moves SpringRunner/SpringClassRule/@Rule based tests to JUnit 5 so junit-vintage-engine can be dropped.
Runs on Boot 2.7, before any version bump.
recipeList:
- org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration

---
type: specs.openrewrite.org/v1beta/recipe
name: org.zalando.zally.migration.Boot2.Step2_Tooling
displayName: Zally Boot 2 migration, step 2 - Gradle wrapper and Kotlin plugins (still on Boot 2.7)
description: >
Gradle 8.0-rc1 -> 8.14.x (needed by the Boot 4 plugin later) and the Kotlin Gradle plugins to 2.2.x.
Dokka, Spotless/ktlint and kapt are NOT covered and have to be bumped by hand.
recipeList:
- org.openrewrite.gradle.UpdateGradleWrapper:
version: 8.14.x
addIfMissing: false
- org.openrewrite.text.FindAndReplace:
# The Kotlin version lives in a local `val kotlinVersion` (root and zally-server build files) and the plugins
# use the kotlin("jvm") shorthand, so UpgradePluginVersion with a plugin id pattern would not match.
find: val kotlinVersion = "1.8.0"
replace: val kotlinVersion = "2.2.21"
filePattern: "**/*.gradle.kts"

---
type: specs.openrewrite.org/v1beta/recipe
name: org.zalando.zally.migration.Boot2.Step3_UpgradeTo35
displayName: Zally Boot 2 migration, step 3 - Spring Boot 2.7 to 3.5 (hand-picked subset)
description: >
Deliberately NOT org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_5. The dry run of that composite on Zally
produced invalid Kotlin (Java-style `Foo.class`), half-converted security configs, a hard-pinned hibernate-core,
a duplicated swagger-models-jakarta and a javax jaxb-api runtime dependency in every module.
This keeps the parts that were correct: Boot plugin version, javax -> jakarta, and property migrations.
Only the zally-server module is rewritten (see init.gradle).
recipeList:
- org.openrewrite.text.FindAndReplace:
# Not UpgradePluginVersion: that recipe also pins hibernate-core to the OLD managed version (5.6.14.Final).
find: id("org.springframework.boot") version "2.7.7"
replace: id("org.springframework.boot") version "3.5.16"
filePattern: "**/zally-server/build.gradle.kts"
- org.openrewrite.java.ChangePackage:
oldPackageName: javax.persistence
newPackageName: jakarta.persistence
recursive: true
- org.openrewrite.java.ChangePackage:
oldPackageName: javax.servlet
newPackageName: jakarta.servlet
recursive: true
- org.openrewrite.java.spring.boot2.SpringBootProperties_2_4
- org.openrewrite.java.spring.boot2.SpringBootProperties_2_7
- org.openrewrite.java.spring.boot3.SpringBootProperties_3_0
- org.openrewrite.java.spring.boot3.SpringBootProperties_3_4_EnabledToAccess
- org.openrewrite.java.spring.boot3.SpringBootProperties_3_5

---
type: specs.openrewrite.org/v1beta/recipe
name: org.zalando.zally.migration.Boot2.Step3b_RemoveLegacyLibraries
displayName: Zally Boot 2 migration, step 3b - drop libraries that have no Boot 3 release (opt-in)
description: >
These are unmaintained and javax based. Removing them breaks compilation on purpose; the replacements are
manual: Spring Security resource server for stups-spring-oauth2-server, a small controller for twintip,
ProblemDetail for problem-spring-web, native OffsetDateTime mapping for jadira usertype.
recipeList:
- org.openrewrite.gradle.RemoveDependency:
groupId: org.zalando.stups
artifactId: stups-spring-oauth2-server
configurations: implementation
- org.openrewrite.gradle.RemoveDependency:
groupId: org.zalando
artifactId: twintip-spring-web
configurations: implementation
- org.openrewrite.gradle.RemoveDependency:
groupId: org.zalando
artifactId: problem-spring-web
configurations: implementation
- org.openrewrite.gradle.RemoveDependency:
groupId: org.jadira.usertype
artifactId: usertype.core
configurations: implementation
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.zalando.zally.rule.api.RuleSet
import java.net.URI

abstract class AbstractRuleSet : RuleSet {

override val id: String
get() = javaClass.simpleName

Expand All @@ -15,9 +14,10 @@ abstract class AbstractRuleSet : RuleSet {

override fun hashCode(): Int = id.hashCode()

override fun equals(other: Any?): Boolean = other != null &&
this.javaClass == other.javaClass &&
this.id == (other as RuleSet).id
override fun equals(other: Any?): Boolean =
other != null &&
this.javaClass == other.javaClass &&
this.id == (other as RuleSet).id

override fun toString(): String = id
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.zalando.zally.core

interface ApiValidator {
fun validate(content: String, policy: RulesPolicy, authorization: String? = null): List<Result>
fun validate(
content: String,
policy: RulesPolicy,
authorization: String? = null,
): List<Result>
}
Loading
Loading