Migrate to Quarkus 2 from Quarkus 1
In this guide we'll look at using OpenRewrite to perform an automated migration from Quarkus 1.x to Quarkus 2.x.
Example Configuration
This recipe has no required configuration options. It can be activated by adding a dependency on `org.openrewrite.recipe:rewrite-quarkus` in your build file or by running a shell command (in which case no build changes are needed):
- Gradle
- Gradle init script
- Gradle init script (Kotlin)
- Maven POM
- Maven Command Line
- Moderne CLI
- Add the following to your
build.gradlefile:build.gradleplugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.quarkus.quarkus2.Quarkus1to2Migration")
}
repositories {
mavenCentral()
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-quarkus:2.33.0")
} - Run
gradle rewriteRunto run the recipe.
- Create a file named
init.gradlein the root of your project.init.gradleinitscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies { classpath("org.openrewrite:plugin:7.34.0") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("org.openrewrite.recipe:rewrite-quarkus:2.33.0")
}
rewrite {
activeRecipe("org.openrewrite.quarkus.quarkus2.Quarkus1to2Migration")
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
} - Run the recipe.shell
gradle --init-script init.gradle rewriteRun
- Create a file named
init.gradle.ktsin the root of your project.init.gradle.ktsinitscript {
repositories {
maven { url = uri("https://plugins.gradle.org/m2") }
}
dependencies { classpath("org.openrewrite:plugin:7.34.0") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin::class.java)
dependencies {
add("rewrite", "org.openrewrite.recipe:rewrite-quarkus:2.33.0")
}
extensions.configure<org.openrewrite.gradle.RewriteExtension> {
activeRecipe("org.openrewrite.quarkus.quarkus2.Quarkus1to2Migration")
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
} - Run the recipe.shell
gradle --init-script init.gradle.kts rewriteRun
- Add the following to your
pom.xmlfile:pom.xml<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.41.0</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.quarkus.quarkus2.Quarkus1to2Migration</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-quarkus</artifactId>
<version>2.33.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project> - Run
mvn rewrite:runto run the recipe.
You will need to have Maven installed on your machine before you can run the following command.
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run --define rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-quarkus:RELEASE --define rewrite.activeRecipes=org.openrewrite.quarkus.quarkus2.Quarkus1to2Migration
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe Quarkus1to2Migration
If the recipe is not available locally, then you can install it using:
mod config recipes jar install org.openrewrite.recipe:rewrite-quarkus:2.33.0
For the full list of changes this recipe will make, see the recipe reference page.
Once you've configured your project, you're ready to execute the migration by running mvn rewrite:run or gradlew rewriteRun. After running the migration you can inspect the results with git diff (or equivalent), manually fix anything that wasn't able to be migrated automatically, and commit the results.
Before and After
Migrate Deprecated Mutiny APIs
- Deprecated Mutiny APIs (Before)
- Deprecated Mutiny APIs (After)
package org.acme.demo.service;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.groups.MultiCollect;
import javax.enterprise.context.ApplicationScoped;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.Executor;
@ApplicationScoped
public class FactorService {
public static Uni<String> uniGreeting(String name) {
return Uni.createFrom().item(name)
.onItem()
.apply(n -> String.format("Factor this %s", n));
}
public static Multi<String> greetings(int count, String name) {
return Multi.createFrom().ticks().every(Duration.ofMillis(1))
.onItem()
.transform(n -> String.format("hello %s - %d", name, n))
.transform()
.byTakingFirstItems(count);
}
public static Uni<List<String>> collectItems(int count, String name) {
Multi<String> multi = greetings(count, name);
Uni<List<String>> uni = multi
.collectItems()
.asList();
Executor e = command -> {
System.out.print("something");
};
multi.subscribeOn(e);
uni.subscribeOn(e);
return uni;
}
public static MultiCollect<Long> hotStreamGreetings(int count, String name) {
return Multi.createFrom().ticks().every(Duration.ofMillis(1))
.transform()
.toHotStream()
.collectItems();
}
}
package org.acme.demo.service;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.groups.MultiCollect;
import javax.enterprise.context.ApplicationScoped;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.Executor;
@ApplicationScoped
public class FactorService {
public static Uni<String> uniGreeting(String name) {
return Uni.createFrom().item(name)
.onItem()
.transform(n -> String.format("Factor this %s", n));
}
public static Multi<String> greetings(int count, String name) {
return Multi.createFrom().ticks().every(Duration.ofMillis(1))
.onItem()
.transform(n -> String.format("hello %s - %d", name, n))
.select()
.first(count);
}
public static Uni<List<String>> collectItems(int count, String name) {
Multi<String> multi = greetings(count, name);
Uni<List<String>> uni = multi
.collect()
.asList();
Executor e = command -> {
System.out.print("something");
};
multi.runSubscriptionOn(e);
uni.runSubscriptionOn(e);
return uni;
}
public static MultiCollect<Long> hotStreamGreetings(int count, String name) {
return Multi.createFrom().ticks().every(Duration.ofMillis(1))
.toHotStream()
.collect();
}
}
Migrate io.quarkus.qute.api.*
- io.quarkus.qute.api.* (Before)
- io.quarkus.qute.api.* (After)
package org.acme.demo.misc;
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.CheckedTemplate;
import io.quarkus.qute.api.ResourcePath;
import io.quarkus.scheduler.Scheduled;
public class ReportGenerator {
@ResourcePath("reports/v1/report_01")
Template report;
@Scheduled(cron = "0 30 * * * ?")
void generate() {
String result = report
.data("samples", new Object())
.render();
}
}
@CheckedTemplate
class HelloTemplate {
public static native TemplateInstance hello(String name);
}
package org.acme.demo.misc;
import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.Location;
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.scheduler.Scheduled;
public class ReportGenerator {
@Location("reports/v1/report_01")
Template report;
@Scheduled(cron = "0 30 * * * ?")
void generate() {
String result = report
.data("samples", new Object())
.render();
}
}
@CheckedTemplate
class HelloTemplate {
public static native TemplateInstance hello(String name);
}
Migrate application.properties keys and values
- application.properties (Before)
- application.properties (After)
quarkus.dev.instrumentation=true
smallrye.jwt.sign.key-location=/keys/signing.pem
smallrye.jwt.encrypt.key-location=/keys/encrypt.pem
quarkus.quartz.force-start=true
quarkus.quartz.store-type=db
quarkus.neo4j.pool.metrics-enabled=true
# ...
# and other property keys/values as according to the Quarkus migration guide
quarkus.live-reload.instrumentation=true
smallrye.jwt.sign.key.location=/keys/signing.pem
smallrye.jwt.encrypt.key.location=/keys/encrypt.pem
quarkus.quartz.start-mode=forced
quarkus.quartz.store-type=jdbc-cmt
quarkus.neo4j.pool.metrics.enabled=true
# ...
# and other property keys/values as according to the Quarkus migration guide
Known Limitations
| Unsupported Functionality | Issue |
|---|---|
@ConfigProperties-annotated interfaces migrate to using @ConfigMapping, but not yet @ConfigProperties-annotated classes | #24 |
| Kubernetes Client 5.4 | - |
| Vert.x 4.0 | - |
See how this recipe works across multiple open-source repositories
Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.