DEV Community

Cover image for I fixed Quarkus dev mode running two Maven steps in the wrong order
Ashok Ram
Ashok Ram

Posted on Originally published at ashokramsi.hashnode.dev AI-assisted

I fixed Quarkus dev mode running two Maven steps in the wrong order

mvn clean compile quarkus:dev generated the gRPC classes. mvn clean quarkus:dev didn't. Same project, same settings, one word apart.

yersan reported that in issue #57633, and I fixed it in quarkusio/quarkus#57866. The cause: two build steps ran back to front, but only in dev mode.

The setup

Quarkus is a Java framework for web services. Dev mode is its live reload mode: start it once, edit your code, and the running app picks up the changes. With gRPC, a way for services to call each other where messages are described in .proto files, Quarkus can generate Java classes from .proto files that sit inside a library you depend on. One line in application.properties turns it on:

quarkus.generate-code.grpc.scan-for-proto=<groupId>:<artifactId>
Enter fullscreen mode Exit fullscreen mode

In dev mode, that line was simply ignored.

The clue was in the log

yersan had already found it:

[INFO] Invoking quarkus:3.40.1.1:generate-code (default-generate-code) @ app
[INFO] Invoking resources:3.3.1:resources (default-resources) @ app
Enter fullscreen mode Exit fullscreen mode

Code generation ran first. Copying resources, the step that puts application.properties into target/classes, ran second. The generator checked for its settings the way a mail carrier might check a mailbox before the letter has been dropped in, found nothing, and moved on.

Why only dev mode

Quick Maven vocabulary: a build is a series of stages called phases, and each phase runs small jobs called goals. The quarkus packaging comes with a recipe that puts two goals in the same phase: resources:resources, then quarkus:generate-code. Maven keeps that order by giving each goal a priority number, and the lowest runs first.

I checked on a small test app: plain mvn clean process-test-resources ran resources before generate-code. Maven was fine.

Dev mode skips Maven for those early goals and calls them directly. It lined them up in the order the plugins are declared and never looked at the priority. The Quarkus plugin is written in your pom.xml, and the resources plugin is one Maven slips in afterwards. So code generation jumped the queue. The test versions of both goals had the same problem.

The fix: do what Maven does

No gRPC special case. Dev mode now sorts each phase's goals by priority. This is the line that does it:

executions.sort(Comparator.comparingInt(pe -> pe.execution.getPriority()));
Enter fullscreen mode Exit fullscreen mode

Java's List.sort is stable, so goals with equal priority stay in their original order and your own plugins don't get shuffled.

One goal needed extra care. If you list generate-code without a phase, dev mode puts a copy of it into compile, and that copy must run before compiling. I gave it Integer.MIN_VALUE, the smallest possible int, so it always sorts first.

Review made it smaller

My first version also kept the old trick of inserting that copy at the front of the list. cescoffier asked: "Why keep the index here?" Fair point. The smallest priority already did that job, so I dropped the insert and added a test that adds the copy last and checks it still lands first.

aloubyansky then asked why a specific priority was needed at all. Without it, the copy shares priority 0 with most goals, so it could land behind an earlier compile goal, and the compiler could then run before the generated code exists. I explained it in the thread and the code stayed the same. Both gsmet and aloubyansky signed off, and aloubyansky hit merge on 5 November 2026.

The lesson

If your code takes over part of another tool's work, follow that tool's ordering rule exactly, not just the order you happened to see in one log. Matching Maven fixed the test goals at no extra cost, and review turned two mechanisms into one.

Have you ever had a dev mode or watch mode behave differently from your normal build? What turned out to be the cause?

The full story, with all the code, is on my blog: https://ashokramsi.hashnode.dev/quarkus-dev-mode-goal-order

Top comments (0)