Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kickstart your Migrations – Grundlagen des Migr...

Kickstart your Migrations – Grundlagen des Migration-Engineering mit OpenRewrite

Jakarta EE oder Spring Boot – die Releases und End-of-Support Meldungen jagen einander. Die Anzahl der notwendigen Migrationen explodiert und der Featuredruck lässt nicht nach.

Mit dem Open Source Werkzeug OpenRewrite lassen sich Migrationen automatisierbar und skalierbar auf Projekte anwenden. Die große und wachsende Menge an vorgefertigten Migrationen bietet Lösungen für viele Situationen an. Durch die Konfiguration und Kombinierbarkeit von vorhandenen Migrationen können zusätzliche Anforderungen schnell umgesetzt werden. Komplexere Anpassungen sind durch die direkte Integration von Refaster Templates einfach umsetzbar.

Diese Session behandelt den Funktionsumfang und die Integration von OpenRewrite in vorhandene Projekte. Ferner werden die Grundlagen der testgetriebenen Entwicklung von Migrationen behandelt. Die Teilnehmer:innen dieser Session erlernen den grundlegenden Umgang mit OpenRewrite und bekommen wertvolle Tipps für den regelmäßigen Einsatz.

Avatar for Merlin Bögershausen

Merlin Bögershausen

April 04, 2025
Tweet

More Decks by Merlin Bögershausen

Other Decks in Programming

Transcript

  1. 12

  2. ©2024 Moderne, Inc. 16 100% accurate, style-preserving transformation because of

    a tech leap in code representation Characterized by serialization, type attribution, format preservation, and other metadata + another 600,000 nodes that didn’t fit in this graphic Text-based search Abstract Syntax Tree (AST) Lossless Semantic Tree (LST)
  3. ©2024 Moderne, Inc. 17 LST Example List.of("A", "B"); Identifier MethodCall

    Literal Literal Identifier Expression . (" "," ) { } ( ) I Ab Ab I Visitor Expression visitExpression(Expression e) MethodCall visitMethodCall(MethodCall m) Identifier visitIdentifier(Identifier i) Literal visitLiteral(Literal l)
  4. 18 Declarative recipes Yaml Configurable Building blocks Composition Simple Refaster

    style recipes Annotated methods Compiler checked Limited applicability Straightforward replacements Starting point Imperative recipes Java visitors Full flexibility Increased complexity JavaTemplate builder Trait API Three types of recipes
  5. ©2024 Moderne, Inc. 19 Please let me see warnings ---

    type: specs.openrewrite.org/v1beta/recipe name:io.github.mboegers.RemoveDeprecationSuppression displayName: Enable deprecation warnings description: Remove SuppressWarnings for deprecation. recipeList: - org.openrewrite.java.RemoveAnnotation: annotationPattern: \ '@java.lang.SuppressWarnings("deprecation")'
  6. ©2024 Moderne, Inc. 20 Replace a Method Invocation @RecipeDescriptor(name =

    "Replace oldOperation", description = "Replace ´oldOperation´ with ´betterOperation´") public static class ReplaceOldOperation { @BeforeTemplate public void oldOperation(SomeService s) { s.oldOperation(); } @AfterTemplate public void newOperation(SomeService s) { s.betterOperation(); } }
  7. ©2024 Moderne, Inc. 21 Imperative Recipe API public class MakePublic

    extends Recipe { public String getDisplayName() { return "Make Class Public"; } @Override protected JavaVisitor<ExecutionContext> getVisitor() { return new ChangeTypeVisitor(); } private class MakePublicVisitor extends JavaVisitor<ExecutionContext> {/*..*/} } class JavaVisitor<P> extends TreeVisitor<J, P> { J visitStatement(Statement statement) {} J visitAnnotatedType(J.AnnotatedType annotatedType) {} J visitAnnotation(J.Annotation annotation) {} J visitAssert(J.Assert azzert) {} J visitAssignment(J.Assignment assign) {} J visitAssignmentOperation(J.AssignmentOperation assignOp) {} //... } Visit method for every Language Component Available
  8. ©2023 Moderne, Inc. 22 Growing ecosystem of modernization recipes Recipes

    programmatically execute automated search and transformation actions on a codebase. The ecosystem of OpenRewrite community-driven recipes is continually growing. Gradle Apache Maven Spring Quarkus Kubernetes Terraform Testcontainers AWS Micronaut Google Cloud Microsoft Azure Github Actions Concourse CircleCI Axon Framework Configuration Scripting Java-like Languages Frameworks, libraries, tooling CI/CD Infrastructure Python
  9. ©2024 Moderne, Inc. 25 Collaborating across the enterprise codebase Moderne

    DevCenter to always know the state of your code and take action. Code visualizations for understanding your code like never before. Code analysis and recipe recommendations Activity tracking and coordination Risk profile of vulnerabilities plus available fixes
  10. ©2024 Moderne, Inc. 27 Moderne scales OpenRewrite automation Single-repository mode

    Multi-repository mode OpenRewrite OSS Project Serialize LSTs to disk OpenRewrite Gradle Plugin OpenRewrite Maven Plugin Broadcom Application Advisor Amazon Q Code Transformation JetBrains OpenRewrite Plugin Microsoft VSCode Plugin Moderne Platform Moderne CLI Single- tenant SaaS On-prem Moderne proprietary IP Moderne DX Air-gapped service Shared OSS recipe ecosystem Codemods, linters, & other refactoring tech
  11. ©2024 Moderne, Inc. 28 Where to learn more docs.openrewrite.org moderne.ai

    app.moderne.io github.com/openrewrite youtube.com/@Moderne-and-OpenRewrite Google Shape;842;p69 O’Reily Book: AI for Mass-Scale Code Refactoring and Analysis
  12. ©2024 Moderne, Inc. 29 Danke! Follow us! Google Shape;850;p70 Google

    Shape;851;p70 Google Shape;852;p70 Google Shape;853;p70 O’Reily Book: AI for Mass-Scale Code Refactoring and Analysis