Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions docs/guides/openrewrite-recipe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
layout: default
title: OpenRewrite Migration
parent: Guides
nav_order: 5
---

# OpenRewrite Migration

{: .fs-9 }

Migrate a Querydsl project to fluentQ automatically with [OpenRewrite](https://docs.openrewrite.org/).
{: .fs-6 .fw-300 }

---

fluentQ publishes an OpenRewrite recipe artifact, **`{{ site.group_id }}:fluentq-rewrite`**, that
rewrites a downstream project from Querydsl to fluentQ — no hand-editing of imports or coordinates.

## What it does

The recipe `io.github.openfeign.fluentq.rewrite.MigrateQuerydslToFluentQ`:

- Renames Java/Kotlin/Scala packages: `com.querydsl.*` and `io.github.openfeign.querydsl.*` → `fluentq.*`
(imports, fully-qualified names, `package` declarations).
- Rewrites Maven coordinates: group id → `{{ site.group_id }}`, artifacts `querydsl-*` → `fluentq-*`,
version → `{{ site.querydsl_version }}` (dependencies, `dependencyManagement`, and the BOM
`querydsl-bom` → `fluentq-bom`).
- Rewrites the build plugin `querydsl-maven-plugin` → `fluentq-maven-plugin`.

It works for both the original Querydsl (`com.querydsl`) and the OpenFeign fork
(`io.github.openfeign.querydsl`).

## Maven

Add the recipe artifact to the `rewrite-maven-plugin` and activate the recipe:

```xml
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.42.0</version>
<configuration>
<activeRecipes>
<recipe>io.github.openfeign.fluentq.rewrite.MigrateQuerydslToFluentQ</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>{{ site.group_id }}</groupId>
<artifactId>fluentq-rewrite</artifactId>
<version>{{ site.querydsl_version }}</version>
</dependency>
</dependencies>
</plugin>
```

```bash
./mvnw rewrite:run
```

Or run it once without editing your `pom.xml`:

```bash
./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.recipeArtifactCoordinates={{ site.group_id }}:fluentq-rewrite:{{ site.querydsl_version }} \
-Drewrite.activeRecipes=io.github.openfeign.fluentq.rewrite.MigrateQuerydslToFluentQ
```

Use `rewrite:dryRun` instead of `rewrite:run` to preview the diff (written to
`target/rewrite/rewrite.patch`) before applying it.

## Gradle

```groovy
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}

rewrite {
activeRecipe("io.github.openfeign.fluentq.rewrite.MigrateQuerydslToFluentQ")
}

dependencies {
rewrite("{{ site.group_id }}:fluentq-rewrite:{{ site.querydsl_version }}")
}
```

```bash
./gradlew rewriteRun # or rewriteDryRun to preview
```

## Limitations & manual steps

- **Annotation processor class in `pom.xml`** — if you configured a processor class by hand the old
way (`<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>`), update the package to
`fluentq.apt.*` manually. The recommended `maven-compiler-plugin` + `annotationProcessorPaths`
setup discovers the processor from the `fluentq-apt` artifact and needs no class change.
- **Dropped modules** — `querydsl-jdo`, `querydsl-lucene3/4/5`, and `querydsl-hibernate-search` have
no fluentQ equivalent and are intentionally left untouched. See the
[Migration Guide](../migration.md) for alternatives.
- **Review the result** — always review the diff and run a full build (`mvn clean install`) after the
recipe; regenerate Q-types and confirm your queries compile.

## Roadmap

The `fluentq-rewrite` artifact is the home for fluentQ migration recipes. Planned additions:

- `MigrateMysemaQuerydslToFluentQ` — ancient Querydsl 3 (`com.mysema`) with its older syntax.
- `MigrateJooqToFluentQ` — migrate from jOOQ.
- `MigrateHibernateCriteriaToFluentQ` — migrate from the Hibernate Criteria API.

Each lives in the same artifact under `META-INF/rewrite/`, so updating the `fluentq-rewrite`
dependency makes new recipes available.
12 changes: 12 additions & 0 deletions docs/migration-8.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ Replace imports of legacy packages with the new `fluentq` package structure:

---

## Automated Migration with OpenRewrite

For a deterministic, repeatable migration, use the published OpenRewrite recipe
`io.github.openfeign.fluentq.rewrite.MigrateQuerydslToFluentQ` (artifact
`{{ site.group_id }}:fluentq-rewrite`). It rewrites the Maven coordinates, the Java/Kotlin/Scala
package imports, and the build plugin in one pass, for both Maven and Gradle projects.

See the [OpenRewrite Migration guide]({{ site.baseurl }}/guides/openrewrite-recipe) for the full
Maven and Gradle setup, the Querydsl 5 variant, and limitations.

---

## Automated Migration with AI / LLM

Since this migration is a mechanical rename of dependencies and package prefixes, you can easily use an AI coding assistant (like Gemini or Claude) to automate the process for you.
Expand Down
76 changes: 76 additions & 0 deletions fluentq-tooling/fluentq-rewrite/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.openfeign.fluentq</groupId>
<artifactId>fluentq-tooling</artifactId>
<version>8.0-SNAPSHOT</version>
</parent>
<artifactId>fluentq-rewrite</artifactId>

<name>FluentQ - OpenRewrite recipes</name>
<description>OpenRewrite recipes that migrate projects to fluentQ</description>

<properties>
<rewrite-recipe-bom.version>3.33.0</rewrite-recipe-bom.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-recipe-bom</artifactId>
<version>${rewrite-recipe-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- The recipe is declarative (META-INF/rewrite/*.yml); the rewrite engine and the
core recipes it composes are supplied by the rewrite plugin at apply time, so no
compile-scope dependencies are required. The dependencies below are test-only. -->
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java</artifactId>
<scope>test</scope>
</dependency>
<!-- Java parser matching the JDK the tests run on (project test toolchain = 25). -->
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-25</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-maven</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>fluentq.rewrite</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading
Loading