How openrewrite/rewrite-gradle-plugin works
Project type and purpose
• This is a Gradle plugin project (“rewrite‑gradle‑plugin”) whose purpose is to integrate the OpenRewrite refactoring engine into a Gradle build as first‑class tasks (e.g. rewriteRun, rewriteDiscover, rewriteDryRun). It allows a consuming project to configure Rewrite recipes via a DSL extension and have them run automatically during the build.
File‑structure analysis
• Top‑level build scripts:
• settings.gradle.kts, build.gradle.kts, gradle.properties, wrapper under gradle/wrapper
• A buildSrc directory containing Groovy classes that generate version data and argument providers used in the publishing/build pipeline.
• plugin module (plugin/):
• src/main/java & src/main/kotlin: plugin entrypoint (RewritePlugin), extension (RewriteExtension), task classes (AbstractRewriteTask & subtypes), project parsers (GradleProjectParser, AndroidProjectParser, DelegatingProjectParser), classloader isolation (RewriteClassLoader), result containers, marker printers.
• src/test: JUnit/Kotlin tests for tasks and parser components, fixtures, sample projects.
• CI & publishing:
• .github/workflows/*.yml orchestrate CI builds, integration tests, publishing to Gradle Plugin Portal, Dependabot updates, backups, stale‑issue management.
README insights
• Clear explanation of plugin usage, configuration via rewrite { activeRecipe(...) }, consumption of snapshots via pluginManagement resolution strategy.
• References to core Rewrite engine (“Rewrite”), and documentation links.
Essential elements without over‑splitting
• Closely related classes (all Task implementations) under one “Rewrite Tasks” boundary.
• Both “GradleProjectParser” and “AndroidProjectParser” as options behind a “Parser” facade.
• Isolated classloader as a separate module to highlight dependency isolation.