Major migrations�made easy
Tim te Beek
Tim te Beek
Java Consultant
2
Major migrations�over the past decade
3
2009
��XML → Annotations
Component scanning
SOAP
Applets
4
2.5
2011
try ( Resource closeable = new Resource() ) { … }
List<String> diamonds = new ArrayList<>()
java.nio.file.Path
5
2014
(Integer x, Integer y) -> { return x + y; }
LocalDate releaseDate = LocalDate.of(2014, 3, 18);
6
2014 - Spring Boot 1.0
Jar not war
Opinionated
Non functionals
No XML
7
2015
Decomposition
Communication & failures
NoSQL
Kubernetes 1.0
8
2017
@BeforeEach, …
@Rule → Extension
@RunWith → @ExtendWith
assertThrows(Exception.class, () -> validate(invalidArgument))
9
2018
List.of()
var
HttpClient
java.xml.ws ❌
java.xml.bind ❌
10
2018 - Spring Boot 2.0
Java 7 ❌ Java 8+ ✅
Configuration Property Binding
WebFlux
Micrometer.io
Spring Data, Security, Cloud, Messaging, …
11
2019
GitHub buys Dependabot
WhiteSource buys Renovate
Increased awareness
❌ = 👩💻
✅ = 🤔
12
2021
Text blocks
record Point ( int x, int y ) { }
if ( object instanceof Integer i ) { }
return switch ( … ) { … };
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
13
2022
14
2022 - Spring Boot 3.0
Java 17 baseline
Jakarta EE 9
Kotlin 1.6
Groovy 4.0
Gradle 7.3
15
Change is the
only constant
16
OpenRewrite
17
Origin
Internal logging framework → SLF4J
Perfect transformation required
Abstract Syntax Tree parser & manipulation
Produce minimal changes
18
Broader application
Onboarding stalled
Struggle with outdated libraries & frameworks
Spring Boot 1.x → 2.x
JUnit 4 → JUnit 5
Apache license 2.0
19
Early focus on JVM
Search & transformation
Refactoring ecosystem
20
AssertJ
Abstract Syntax Tree
Type attribution
Format preservation
21
Recipes
Search & Refactor
Composition
22
Visitors
Match & modify elements
23
Modules
Search & Refactor
Composition
Specific purpose
Complete migrations
24
JUnit 5 recipe
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.JUnit4to5Migration
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.junit.Test
newFullyQualifiedTypeName: org.junit.jupiter.api.Test
- org.openrewrite.java.testing.junit5.UpdateBeforeAfterAnnotations
- org.openrewrite.java.testing.junit5.AssertToAssertions
- org.openrewrite.java.testing.junit5.StaticImports
- org.openrewrite.java.testing.junit5.ExpectedExceptionToAssertThrows
- …
25
JUnit 5 recipe
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.JUnit4to5Migration
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.junit.Test
newFullyQualifiedTypeName: org.junit.jupiter.api.Test
- org.openrewrite.java.testing.junit5.UpdateBeforeAfterAnnotations
- org.openrewrite.java.testing.junit5.AssertToAssertions
- org.openrewrite.java.testing.junit5.StaticImports
- org.openrewrite.java.testing.junit5.ExpectedExceptionToAssertThrows
- …
26
Large migrations in small reusable steps
27
Running recipes
./mvnw org.openrewrite.maven:rewrite-maven-plugin:4.24.0:run� -Drewrite.recipeArtifactCoordinates=� org.openrewrite.recipe:rewrite-spring:4.21.0� -DactiveRecipes=� org.openrewrite.java.spring.boot2.SpringBoot1To2Migration
28
PetClinic Migration
Spring Boot 1.5.x → 2.x
Java 8 → Java 17
JUnit 4 → JUnit 5
29
Demo
30
Applications
OpenRewrite
Migrate
Fix
Enforce
31
Future
OpenRewrite
Kotlin
Java 17
Typescript
32
Spring Boot Migrator
33
“Spring Boot Migrator (SBM) aims to help developers�upgrade or migrate to Spring Boot by providing recipes for automated migrations.”
34
Origin
35
Strong Spring focus
Java EE → Spring Boot
MuleSoft → Spring Integration
Upgrade Spring Boot
Adopt Spring Cloud
36
Inform & guide
With HTML report
37
Apply & iterate
Through interactive CLI
38
Future
Spring Boot Migrator
Spring Framework 6 & Boot 3
Introduce new Spring Module
Generate context related code
Contextual guidance
39
Moderne
40
Apply at scale
Committed to Open Source Recipes
41
app.moderne.io
42
Contribute to Open Source
Find project in need of ❤️
Reduce technical debt 👷
Keep review effort comparable 🔍
Report missing recipes 🐛
Finish Spring PetClinic migration 🐶
43
We could all use�more automation
44
Closing
45
Migrate safely,�quickly & in full
46
Where to learn more
docs.openrewrite.org
github.com/openrewrite
github.com/spring-projects-experimental/spring-boot-migrator
app.moderne.io
RewriteOSS.slack.com
47
48
Questions
49
Thank you!
50
51
52
53
54
55
56
57