How moderneinc/rewrite-recipe-starter works
Main Components
• Codebase / Recipe Modules:
• Core Recipe Implementations: Located under src/main/java – these include classes such as NoGuavaListsNewArrayList, SimplifyTernary, AssertEqualsToAssertThat, etc. They encapsulate individual transformation logic.
• YAML-based Recipes: Found under src/main/resources/META-INF/rewrite – these offer declarative recipes (for instance, stringutils.yml).
• Utility & Configuration Files: E.g., logback.xml and the META-INF configurations that support the OpenRewrite engine.
• Test Suite:
• Unit Tests for verifying each recipe. They reside in the src/test directory.
• Build & Dependency Management:
• Gradle and Maven Build Files: build.gradle.kts, pom.xml, settings.gradle.kts, and accompanying wrapper scripts (gradlew, mvnw) denote support for both build systems.
• CI/CD and Deployment:
• Github Workflows: Located under .github/workflows – these define CI pipelines for building, testing, and publishing snapshots/releases.
• Publishing Components: The configuration details in the README describe local publishing and integration with Moderne’s open artifact repository, along with instructions for Maven Central.
Relationships and Interactions
• Recipe Development Lifecycle:
• Developer edits recipe classes (core logic) and YAML files.
• Unit tests in src/test validate the transformation behavior.
• Build and Test Pipeline:
• The CI (GitHub Actions workflows) triggers the build scripts, which run tests via Gradle/Maven.
• Artifacts are created and published either to a local Maven repository or to Moderne’s repository.
• External Integration:
• The published recipe JAR is intended to be consumed by the OpenRewrite engine (via rewrite-maven-plugin or Gradle configuration) and eventually applied on app.moderne.io.
Architectural Patterns and Design Principles
• Separation of Concerns: The code is clearly separated into implementation (src/main) and testing (src/test), as well as build/publishing configuration at the project root.
• Plugin/Recipe Based Architecture: Recipes are treated as modular, independently testable units which can be swapped in and out. This represents extensibility.
• Multi-tool Build Integration: Supports both Maven and Gradle tools, which indicates an architecture designed for flexibility in deployment and testing.
• CI/CD Automation: GitHub Actions scripts illustrate an automated pipeline from commit to artifact publication.
Relevant Technologies, Frameworks, and Libraries
• Java: The primary implementation language.
• OpenRewrite: The framework/concept behind building and executing recipes.
• Gradle and Maven Tools: For building and publishing the project.
• GitHub Actions: For running CI/CD pipelines.
• Logging (logback.xml): Used for logging throughout the execution.
• YAML Configuration: For declarative recipe definitions.