Implementation:Apache Druid OpenRewrite Migration Recipes
| Knowledge Sources | |
|---|---|
| Domains | Code_Migration, Testing, Build |
| Last Updated | 2026-02-10 10:00 GMT |
Overview
rewrite.yml defines OpenRewrite automated code migration recipes used to modernize and standardize the Apache Druid codebase.
Description
This YAML file contains multiple OpenRewrite recipe definitions that automate repetitive code transformations across the Druid project. The top-level recipe org.apache.druid.RewriteRules orchestrates sub-recipes for migrating Calcite-based tests from JUnit 4 to JUnit 5, removing obsolete test runners, upgrading Apache Commons Lang, and converting Jackson Codehaus imports to FasterXML. A detailed custom JUnit4-to-5 migration recipe (org.apache.druid.JUnit4to5Migration) handles annotation updates, assertion migrations, dependency swaps, and plugin version upgrades across the entire Maven build.
Usage
Run these recipes via the OpenRewrite Maven plugin to perform automated code migrations. This is typically done when upgrading test frameworks or libraries across the Druid codebase.
Code Reference
Source Location
- Repository: Apache Druid
- File: rewrite.yml
- Lines: 1-159
Signature
# Top-level composite recipe
type: specs.openrewrite.org/v1beta/recipe
name: org.apache.druid.RewriteRules
recipeList:
- org.apache.druid.UpgradeCalciteTestsToJunit5
- org.openrewrite.java.testing.junit5.RemoveObsoleteRunners
- org.openrewrite.apache.commons.lang.UpgradeApacheCommonsLang_2_3
- org.openrewrite.java.jackson.CodehausToFasterXML
# Calcite test upgrade (scoped to CalciteTestBase subclasses)
name: org.apache.druid.UpgradeCalciteTestsToJunit5
# EasyMock runner replacement
name: org.apache.druid.EasyMockRunnerToEasyMockExtension
# Custom JUnit 4 to JUnit 5 migration (40+ sub-recipes)
name: org.apache.druid.JUnit4to5Migration
Import
# Execute the rewrite recipes via Maven
mvn rewrite:run -Drewrite.recipeArtifactCoordinates=org.openrewrite:rewrite-testing-frameworks:LATEST \
-Drewrite.activeRecipes=org.apache.druid.RewriteRules
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Java source files | .java | Yes | The Java source and test files in the Druid codebase to be transformed |
| pom.xml files | XML | Yes | Maven POM files for dependency and plugin version updates |
| rewrite.yml | YAML | Yes | This recipe definition file, consumed by the OpenRewrite engine |
Outputs
| Name | Type | Description |
|---|---|---|
| Modified Java source files | .java | Updated test files with JUnit 5 annotations, imports, and assertions |
| Modified pom.xml files | XML | Updated Maven POMs with new dependency versions and removed obsolete dependencies |
Usage Examples
Run All Migration Recipes
# Apply all Druid rewrite rules
mvn rewrite:run \
-Drewrite.activeRecipes=org.apache.druid.RewriteRules
Dry Run to Preview Changes
# Preview what changes would be made without applying them
mvn rewrite:dryRun \
-Drewrite.activeRecipes=org.apache.druid.RewriteRules
Run Only JUnit Migration
# Apply only the JUnit 4 to 5 migration
mvn rewrite:run \
-Drewrite.activeRecipes=org.apache.druid.JUnit4to5Migration