Automate repetitive code refactoring and migrations with reusable recipes that make large-scale code changes faster, safer, and more consistent.
Key Features
- Automate repetitive refactoring and migrations across codebases
- Create declarative, Refaster template, and imperative recipes
- Apply custom transformations through your existing build pipeline
- Purchase of the print or Kindle book includes a free PDF eBook
Book Description
Automate repetitive refactoring and make large-scale code changes consistent and scalable with OpenRewrite. This book shows you how to use existing recipes and create your own transformations, helping you modernize codebases while significantly reducing the time and errors associated with manual changes.
You’ll begin with lossless semantic trees (LSTs), recipes, visitors, and styles to understand how OpenRewrite represents and transforms source code. You’ll then learn to find, configure, compose, and run recipes, add recipe sources, and integrate transformations with your build pipeline.
Next, you’ll create declarative recipes and Refaster templates before progressing to imperative recipes. You’ll work with visitors, cursors, shared data, non-isomorphic transformations, configuration options, testing, validation, and multiple visitors. All examples are visualized using Java as a programming language.
Written by freelance software engineer Ansgar Schulte, who brings many years of project experience and has taught more than 15,000 students, this book connects OpenRewrite concepts with techniques you can apply to real projects. By the end, you’ll be able to automate recurring refactoring tasks and build reusable recipes for your own codebases.
What you will learn
- Understand recipes, visitors, styles, and LSTs
- Find, configure, compose, and run OpenRewrite recipes
- Add and use new recipe sources in your projects
- Create declarative and Refaster template recipes
- Build imperative recipes with visitors and cursors
- Test, validate, and configure custom recipes
- Understand isomorphic and non-isomorphic visitors
- Implement complex transformations with multiple visitors
- Integrate automated refactoring into build pipelines
Who this book is for
Software developers and solution architects who spend significant time on manual refactoring, migrations, or technical debt reduction will benefit from this book. You should understand Java syntax and have access to a Java development environment with a JDK, IDE, and build tool. No previous OpenRewrite knowledge or refactoring experience is required.