> ## Documentation Index
> Fetch the complete documentation index at: https://backstage.spotify.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Fleetshift: OpenRewrite Shifts

> Run OpenRewrite recipes across your fleet without requiring target repositories to have OpenRewrite configured.

Fleetshift's OpenRewrite shift type runs [OpenRewrite](https://docs.openrewrite.org/)
recipes across targeted repositories. The target repos do not need OpenRewrite configured —
Fleetshift injects the OpenRewrite plugin at invocation time and auto-detects whether each
repository uses Maven, Gradle, or JavaScript/TypeScript (from `pom.xml`, `build.gradle`, or
`package.json`).

This is useful for fleet-wide code transformations like dependency upgrades, import cleanup,
type renames, and framework migrations.

## Creating an OpenRewrite shift

In the Fleetshift wizard, select `OpenRewrite` as the shift type and fill in the following
fields:

| Field              | Required | Description                                                                                                                |
| ------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| Recipes            | Yes      | Comma-separated fully qualified recipe names (e.g. `org.openrewrite.java.ChangeType`). At least one is required.           |
| Recipe artifacts   | No       | Select additional Apache 2.0 licensed modules from the dropdown. Only needed for recipes outside the built-in set.         |
| Custom rewrite.yml | No       | Define composite recipes or pass parameters to parameterized recipes. Replaces `rewrite.yml` in the target workspace root. |

Configure targets, PR template, and other settings as usual, then click **Create**.

## Available recipes

### Built-in recipes

These are available without selecting any recipe artifact. They cover the core OpenRewrite
modules: `core`, `text`, `java`, `maven`, `xml`, `yaml`, `json`, `properties`, `protobuf`,
`hcl`, and `toml`.

| Recipe                                           | What it does                                   |
| ------------------------------------------------ | ---------------------------------------------- |
| `org.openrewrite.text.FindAndReplace`            | Fleet-wide find and replace with regex support |
| `org.openrewrite.java.ChangeType`                | Replace one Java type with another             |
| `org.openrewrite.java.ChangePackage`             | Rename or move a package                       |
| `org.openrewrite.java.ChangeMethodName`          | Rename methods across call sites               |
| `org.openrewrite.java.OrderImports`              | Organize import statements                     |
| `org.openrewrite.java.RemoveUnusedImports`       | Remove unused imports                          |
| `org.openrewrite.maven.UpgradeDependencyVersion` | Bump a Maven dependency version                |
| `org.openrewrite.yaml.ChangePropertyKey`         | Rename a YAML property key                     |
| `org.openrewrite.yaml.ChangePropertyValue`       | Update a YAML property value                   |

### Recipe artifact modules

Select these in the **Recipe artifacts** dropdown when you need recipes beyond the built-in
set.

| Module                      | Use case                                                  |
| --------------------------- | --------------------------------------------------------- |
| `rewrite-java-dependencies` | Cross-build-tool (Maven + Gradle) dependency management   |
| `rewrite-jackson`           | Jackson Codehaus→FasterXML migration, Jackson 2→3 upgrade |
| `rewrite-quarkus`           | Quarkus version upgrades (3.0 through 3.37)               |
| `rewrite-micronaut`         | Micronaut 2→3→4→5 migrations                              |
| `rewrite-openapi`           | Swagger 2.0 → OpenAPI 3.0 annotation migration            |
| `rewrite-netty`             | Netty 3→4 and 4.1→4.2 migration                           |

<Note>
  Modules under the Moderne Source Available License (`rewrite-spring`,
  `rewrite-static-analysis`, `rewrite-migrate-java`,
  `rewrite-testing-frameworks`, etc.) are not available.
</Note>

## Finding recipes

The [OpenRewrite recipe catalog](https://docs.openrewrite.org/recipes) is a searchable
index of every available recipe. Recipe names follow the convention
`org.openrewrite.<module>.<RecipeName>`.

Composite recipes like `Micronaut3To4Migration` bundle many individual recipes — check the
catalog page for a given recipe to see what it includes.

## Using a custom rewrite.yml

Use a custom `rewrite.yml` when you need to chain multiple recipes into a composite recipe
or pass parameters to a parameterized recipe.

```yaml theme={"theme":{"light":"github-light","dark":"dracula"}}
type: specs.openrewrite.org/v1beta/recipe
name: com.mycompany.MyCustomRecipe
recipeList:
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: com.old.Type
      newFullyQualifiedTypeName: com.new.Type
  - org.openrewrite.java.ChangePackage:
      oldPackageName: com.old.pkg
      newPackageName: com.new.pkg
```

Then enter `com.mycompany.MyCustomRecipe` in the **Recipes** field.

## Examples

### Migrate Swagger to OpenAPI annotations

**Recipes field:** `org.openrewrite.openapi.swagger.MigrateFromSwaggerToOpenAPI`

**Recipe artifact:** `rewrite-openapi`

No custom `rewrite.yml` needed — this recipe has no required parameters.

### Upgrade Jackson 2 to 3

**Recipes field:** `org.openrewrite.java.jackson.UpgradeJackson2_3`

**Recipe artifact:** `rewrite-jackson`

No custom `rewrite.yml` needed.

### Fleet-wide find and replace

**Recipes field:** `com.mycompany.RenameService`

No artifact needed. Add a custom `rewrite.yml` to pass parameters:

```yaml theme={"theme":{"light":"github-light","dark":"dracula"}}
type: specs.openrewrite.org/v1beta/recipe
name: com.mycompany.RenameService
recipeList:
  - org.openrewrite.text.FindAndReplace:
      find: old-service-name
      replace: new-service-name
```

### Upgrade a Maven dependency across repos

**Recipes field:** `com.mycompany.UpgradeGuava`

**Recipe artifact:** `rewrite-java-dependencies`

```yaml theme={"theme":{"light":"github-light","dark":"dracula"}}
type: specs.openrewrite.org/v1beta/recipe
name: com.mycompany.UpgradeGuava
recipeList:
  - org.openrewrite.java.dependencies.UpgradeDependencyVersion:
      groupId: com.google.guava
      artifactId: guava
      newVersion: 33.x
```

## Limitations

* Only Maven, Gradle, and JavaScript/TypeScript projects are supported (auto-detected from
  `pom.xml`, `build.gradle`, or `package.json`).
