Build toolssenior8+ years

A parent POM lists three modules — `orders-domain`, `orders-api`, `orders-worker` — with no explicit build order given anywhere. How does Maven decide what order to build them in, and what stops a developer from accidentally importing `orders-api` classes into `orders-domain`?

Maven doesn't need an explicit build order written anywhere, because it derives one from the modules' own inter-dependencies: if orders-api declares a dependency on orders-domain by coordinates, exactly like a dependency on any external library, Maven's reactor works out that orders-domain has to be built first and orders the whole multi-module build accordingly. Nothing stops a developer from trying to import orders-api classes into orders-domain at the source level — that's not a language restriction — but the build itself stops it: if orders-domain's own POM never declares orders-api as a dependency, its classpath during compilation never includes orders-api's classes at all, so an import that reaches for them simply fails to compile, not because anyone reviewed the code, but because the compiler can't find the class.

The lesson behind it →
More on Build tools