A Quarkus extension is a pluggable module that integrates a library or framework with Quarkus. Add only the capabilities an application needs instead of packaging a monolithic set of integrations. This reduces packaged code and resources, helping startup time and memory use. section 2.7.1 section 2.7
An extension can contribute at build time, at runtime, or both. Its integration code can perform initialization, add configuration properties, and supply information needed for native compilation. For example, an extension can register classes that its library accesses reflectively, sparing application developers much of that native-image configuration. A library does not always need its own extension, but an extension can make using it considerably easier. section 2.7.2 section 12.0 section 12.1.8
To use an existing extension:
- Find candidates with `quarkus extension list --installable`; categories can narrow the search, such as `quarkus extension list --installable --category "messaging"`. section 2.7.3
- Add one with `quarkus extension add "quarkus-messaging-kafka"`. Quarkus adds its Maven dependency; use `quarkus extension list` to see installed extensions or `quarkus extension remove` to uninstall one. section 2.7.3
A custom extension usually has two Maven modules: a deployment artifact used during the build and a runtime artifact included on the application's runtime classpath. Deployment processors run build steps that exchange build items; they can scan indexed application classes and invoke recorders to produce bytecode needed at runtime. Configuration can distinguish build-time properties from runtime properties. A value already acted on during the build cannot be changed effectively when the application starts. section 12.6 section 12.1.3
A metadata extension
A small custom extension adds an HTTP endpoint returning an application's name, version, and runtime dependencies as JSON. Build and install the extension with `mvn install`, then add its dependency to a Quarkus application. Calling `/metadata` verifies the endpoint; setting `quarkus.metadata.path=/some-other-path` and restarting moves it to the new path. Tests can check both the returned data and the configurable path. section 12.3 section 12.3.6 section 12.5
Custom extensions are an advanced option, not a requirement for every library. Before creating one for shared use, check whether a similar extension already exists in Quarkiverse. Extension-writing options extend beyond these basics. section 12.0 section 12.2
