Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Quarkus extensions give Java dependencies superpowers

September 6, 2023
Kevin Dubois
Related topics:
JavaKubernetesQuarkus
Related products:
Red Hat build of Quarkus

Share:

    Quarkus extensions are one of Quarkus' best hidden-in-plain-sight features. Read on to learn how Quarkus extensions give Java superpowers and how you can get started with them.  

    What are Quarkus extensions?

    Quarkus extensions are essentially adapter layers for Java-based libraries or technologies that enhance your application.

    However, the scope of Quarkus extensions goes well beyond "just" importing dependent libraries. They can significantly increase the application's performance, help developers be more productive while developing their applications, integrate complex dependencies much easier, and simplify the application's source code.

    Examples of Quarkus extensions include the Java Database Connectivity (JDBC) libraries, OpenAPI generators, Kubernetes manifest generators, and Apache Camel components. But there are many, many more.  

    Quarkus extensions enhance app performance

    A significant advantage of using Quarkus extensions is that they integrate seamlessly into the Quarkus architecture to take advantage of its superb build time optimization phase. This way, extensions can prescribe how to load and scan your application's bytecode (including the dependencies) and configuration optimally during the build augmentation stage instead of during startup time. This allows for significantly reduced resource usage and a much faster startup time for the application's dependent libraries and technologies, just like the core Quarkus components.

    Extensions also get access to the preparation phase for GraalVM native compilation so that they can leverage the advantages of natively compiled Quarkus binaries. Keep in mind that it is the extension's responsibility to make sure it is compatible with native compilation, so make sure to read its documentation. For a deeper understanding of how this works, check out the Quarkus documentation on how to write an extension.

    Quarkus extensions increase developer productivity and joy

    Aside from aiding the performance of your application, Quarkus extensions can give a significant boost to developer productivity and help make developing applications more enjoyable as well by not having to fiddle around with configurations, extend the Quarkus CLI, and being able to leverage Quarkus's Dev Mode.

    Dev Mode

    Quarkus Dev Mode is a feature that starts up the application locally (or even remotely) and provides a set of capabilities to allow developers to iterate and test their code changes quickly. Dev Mode does targeted hot reloads on the fly when you change your code. This has the benefit of not needing to do manual restarts or rebuilding the application each time you change something. 

    This benefit applies to extensions as well. They will only be (re-)loaded if they have been changed, added, or removed. Any dependent configuration of the extension, such as a database migration script or similar, will also have the same behavior. For example, if you include an import.sql, the import statement will run only during Dev Mode startup or when the file gets changed.

    Dev Services

    Extensions can also leverage the Quarkus Dev Services capability. Dev Services provides an automated way to spin up dependent services, typically in a local container and usually using the Testcontainers project. Think of databases, Apache Kafka clusters, Keycloak, etc. Dev Services are wired into your application without further configuration, making them a powerful way to increase developer productivity because you don't have to worry about setting up complicated dependent services on your local machine.

    To use Dev Services, all you have to do is add the relevant extension—e.g. jdbc-postgresql or camel-quarkus-kafka (Figure 1)—and when you start up Quarkus's Dev Mode (using the command quarkus dev or mvn quarkus:dev), the extension will start up a Dev Service automatically. Because Dev Services usually rely on containers, you will need to have a container runtime on your machine such as Podman or Docker to enjoy this feature (Figure 2).

    adding the camel-quarkus-kafka extensions automatically starts up a Kafka Dev Service
    Figure 1: Adding the camel-quarkus-kafka extension automatically starts a Kafka Dev Service during Dev Mode.
    Kafka Dev Service running in Podman Desktop
    Figure 2: The running Kafka Dev Services container (using an image provided by Redpanda) shown in Podman Desktop

    Dev UI

    When Quarkus runs in Dev Mode, it also serves a web application called the Dev UI, which, among other things, shows the extensions currently used by your application. Extensions can expose additional information and capabilities in the Dev UI. At the minimum, they show details of the extension or a link to further documentation (which can be very handy!).

    Extensions can add actionable capabilities to the Dev UI as well (Figure 3). For many extensions, you can change the configuration on the fly through the Dev UI, and some extensions have purpose-built capabilities such as building a container image, deploying to Red Hat OpenShift, accessing and interacting with the Swagger UI, or even adding records to a Kafka topic running in a Dev Service. Of course, these capabilities depend on the extension and what has been implemented for it.

    Quarkus Dev UI
    Figure 3: Sample extensions shown in the Dev UI.

    Extensions with a related Dev Service will also display the configuration that was automatically generated by Quarkus when the Dev Service started up. This can be very useful for developers to determine what configuration settings are needed for a particular dependency, such as the data source's type, JDBC URL, username, and password, as you can see in Figure 4.

    Quarkus Dev UI showing Kafka and Postgresql Dev Services
    Figure 4: Dev Services shown in the Quarkus Dev UI.

    Quarkus CLI

    The quarkus command lets you create projects, manage extensions, and do essential build and development tasks using the underlying project build tool (e.g., Maven or Gradle). Extensions can extend the functionality of the Quarkus CLI commands by virtue of Quarkus CLI plug-ins (Figure 5). This plug-in system can dynamically add commands and subcommands to the CLI. Some plug-in extensions are available out of the box, which you can retrieve with the Quarkus plug-in list-installable command. In addition, you can also install executable jars from community extensions using their Maven coordinates. 

    List of Quarkus CLI plugins
    Figure 5: An example list of available Quarkus CLI plug-ins.

    Quarkus extensions catalog and versioning

    Quarkus has an extensive catalog of official Quarkus extensions. To get an idea of the extensions that are available for Quarkus, take a look at the quarkus.io extensions catalog page.

    There is no need to keep track of the versioning of any individual extension, thanks to the concept of the Quarkus platform. This concept promises that any combination of the Quarkus extensions within the platform can be used in the same application without causing conflict. This also means that the versions of the extensions are determined by the platform. In practice, this works through the use of a Quarkus platform BOM artifact, which is imported as a dependency on your project.

    Thanks to this Quarkus platform concept, you don't have to explicitly define the version of each Quarkus extension (or the libraries they are acting as a wrapper for) in your pom.xml or build.gradle file, and when you upgrade your Quarkus version, your extension versions are also automatically updated. Bear in mind that the extensions catalog might also contain extensions that are not necessarily production-ready, so it's always a good practice to read up on the extension's documentation before using it.

    The Quarkiverse

    The Quarkiverse GitHub organization provides hosting for Quarkus extension projects—not only for the ones that are featured in the main Quarkus extensions catalog, but also for additional extensions provided by Quarkus community developers. These community extensions are fully maintained by the extension's independent development teams and are typically kept up to date so that they are compatible with the different Quarkus versions. However, there are no explicit guarantees, so ensuring the project is active and up-to-date before using them is essential.

    How to add extensions to your Quarkus project

    You can add a Quarkus extension in a few ways:

    • If you're generating a new project using code.quarkus.io or the supported Red Hat build of Quarkus, code.quarkus.redhat.com, you can select the extensions from the list and they will automatically be added to the generated code starter.
    • Using the Quarkus CLI, you can add extensions using the quarkus extension add command. For example, to add the OpenShift client extension to your project, you would type quarkus extension add quarkus-openshift-client. (Quarkus will automatically resolve it to quarkus.io:quarkus-openshift-client).
    • If you're developing with VS Code or IntelliJ IDEA, you can also use the Quarkus plug-in to add extensions to your project, as illustrated in Figure 6.
    How to add extensions with Quarkus Plugin for VS Code
    Figure 6: Select "Quarkus: Add extensions to current project" in the VS Code command palette.

    Go forth and extend your Quarkus application!

    This was a brief introduction to Quarkus extensions. If you want to learn more about Quarkus, check out the Quarkus overview on Red Hat Developer, or get started with Quarkus tutorials on developers.redhat.com/learn. If you want to learn even more about how Quarkus extensions work, or perhaps how to build your own extension, you can find more information on quarkus.io.

    Last updated: September 19, 2023

    Related Posts

    • Why should I choose Quarkus over Spring for my microservices?

    • OpenTelemetry: A Quarkus Superheroes demo of observability

    • Quarkus for Spring developers: Kubernetes-native design patterns

    • Integrating systems with Apache Camel and Quarkus on Red Hat OpenShift

    • Red Hat build of Quarkus 2.2: Simplified Kubernetes-native Java

    • Build your first Java serverless function using a Quarkus quick start

    Recent Posts

    • How Trilio secures OpenShift virtual machines and containers

    • How to implement observability with Node.js and Llama Stack

    • How to encrypt RHEL images for Azure confidential VMs

    • How to manage RHEL virtual machines with Podman Desktop

    • Speech-to-text with Whisper and Red Hat AI Inference Server

    What’s up next?

    Quarkus for Spring Developers

    Learn how to optimize Java for today’s compute and runtime demands with Quarkus. Quarkus for Spring Developers introduces Quarkus to Java developers, with a special eye for helping those familiar with Spring’s conventions make a quick and easy transition.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue