releases all the time • New minor release every 6 month, sometimes new major releases • It is super important to stay up-to-date • But it is sometimes hard to always stay up-to-date Where are we?
you use • Show information about new versions and support ranges Help the user to upgrade • Migration guides written in “code” • Looks at your project and applies necessary changes - AUTOMATICALLY • Some limitations apply What is new to Spring Tools?
not all of them • The goal is to automate as much as possible • There is no guarantee that you are done with the upgrade afterwards - probably additional manual steps needed ◦ But this will improve with every tools release - of course… 😉 Limitations
transformation framework.” • “OpenRewrite enables large-scale distributed source code refactoring for framework migrations, vulnerability patches, and API migrations” • Automatically transform source code (for various purposes) • https://docs.openrewrite.org/ • https://github.com/openrewrite Based on initial work at Netflix to keep source code up-to-date. Sponsored now by Moderne.io. The Moderne SaaS allows organizations to run search and transformations across hundreds of repositories (millions of lines of code) simultaneously and offer a free service for the OSS community at https://public.moderne.io/ Under the hood
Migrate from Java 8 to Java 11 to Java 17… • Migrate between framework versions • Automatically adapt code to changed APIs • … • Works across various source file types (like Java Source Code, property files, YAML, other languages, etc.) Purpose
files into AST ◦ Type resolution ◦ Keep formatting intact • Step 2: Run visitors on ASTs to transform them ◦ Visitors contain the logic what exactly to do for the refactoring, the migration, the code fix, etc. • Step 3: Generate source changes The internals
a huge set of basic transformation recipes pre-packaged and ready-to-use ◦ https://docs.openrewrite.org/reference/recipes • It is easy to use them and write custom recipes • Community around recipes • Packages could bring their own recipes ◦ E.g. a library contains recipes to migrate client code to a new version of the library The power behind it
./mvnw rewrite:discover - Lists all the available recipes • ./mvnw rewrite:run - Runs the recipes configured as active (in the build config) • ./mvnw rewrite:dryRun - Runs the recipes, but creates a patch file instead of changing the files directly
them • A preference allows you to add your own recipes to the language server • Write them in one workspace, test them in another • No need to restart the IDE, just press “Refresh”
push this beyond running recipes on projects • Let’s combine this with validations/markers and code actions/quick fixes • This goes beyond what OpenRewrite supports out-of-the-box, but it can be added on top
part of the Spring Tools: https://github.com/spring-projects/sts4/ • Independent of Spring Tooling in the future? • Contact us on Twitter: http://twitter.com/springtools4/ Resources