Bazel rules for building Quarkus applications with build-time augmentation support.
rules_quarkus provides native Bazel support for building Quarkus applications, filling the gap where no official Bazel rules exist for the Quarkus framework. The project implements Quarkus's unique build-time augmentation process within Bazel's build system, enabling developers to use Bazel's powerful dependency management and caching while maintaining full Quarkus functionality.
Add the following to your MODULE.bazel:
bazel_dep(name = "rules_quarkus", version = "0.1.0")
# Add Quarkus dependencies
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "maven",
artifacts = [
"io.quarkus:quarkus-arc:3.20.1",
"io.quarkus:quarkus-rest:3.20.1",
"io.quarkus:quarkus-vertx-http:3.20.1",
"jakarta.ws.rs:jakarta.ws.rs-api:4.0.0",
# ... add more dependencies as needed
],
)Create a BUILD.bazel file:
load("//quarkus:quarkus.bzl", "quarkus_application")
quarkus_application(
name = "my-app",
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**/*"]),
# Regular dependencies (APIs)
deps = [
"@maven//:jakarta_ws_rs_jakarta_ws_rs_api",
"@maven//:jakarta_enterprise_jakarta_enterprise_cdi_api",
],
# Quarkus runtime extensions
runtime_extensions = [
"@maven//:io_quarkus_quarkus_arc",
"@maven//:io_quarkus_quarkus_rest",
"@maven//:io_quarkus_quarkus_vertx_http",
],
# Quarkus deployment modules (for build-time processing)
deployment_extensions = [
"@maven//:io_quarkus_quarkus_arc_deployment",
"@maven//:io_quarkus_quarkus_rest_deployment",
"@maven//:io_quarkus_quarkus_vertx_http_deployment",
],
# Main class (required)
main_class = "io.quarkus.runner.GeneratedMain",
)Build and run:
# Build the application
bazel build //:my-app
# Run the application
./bazel-bin/my-app/my-app
# Access your endpoints
curl http://localhost:8080/hellorules_quarkus supports a wide range of Quarkus extensions organized in 5 tiers:
| Extension | Description |
|---|---|
quarkus-arc |
CDI dependency injection |
quarkus-rest |
RESTful web services |
quarkus-rest-jackson |
JSON serialization |
quarkus-vertx-http |
HTTP server |
quarkus-mutiny |
Reactive programming |
| Extension | Description |
|---|---|
quarkus-reactive-oracle-client |
Reactive Oracle database client |
quarkus-reactive-mysql-client |
Reactive MySQL database client |
quarkus-redis-client |
Redis client |
| Extension | Description |
|---|---|
quarkus-messaging-kafka |
Apache Kafka messaging |
quarkus-messaging-rabbitmq |
RabbitMQ messaging |
quarkus-grpc |
gRPC services |
| Extension | Description |
|---|---|
quarkus-micrometer-registry-prometheus |
Prometheus metrics |
quarkus-smallrye-health |
Health checks |
| Extension | Description | Version |
|---|---|---|
quarkus-unleash |
Feature flags | 1.10.0 |
quarkus-langchain4j-* |
AI/LLM integration | 0.26.1 |
quarkus-tika |
Content analysis | 2.1.0 |
rules_quarkus implements Quarkus's three-layer build architecture in Bazel:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Layer 1: β β Layer 2: β β Layer 3: β
β Compile βββββΆβ Augment βββββΆβ Runtime β
β β β β β β
β java_library β β QuarkusBootstrapβ β Executable β
β Standard β β Build-time β β Application β
β compilation β β processing β β with CDI, etc. β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
Standard Java compilation using Bazel's java_library. Source files are compiled to bytecode with minimal processing.
Quarkus build-time augmentation using the official QuarkusBootstrap API:
- Jandex bytecode indexing
- CDI proxy generation
- Configuration processing
- Extension discovery
- Optimized bytecode generation
Executable application with fully processed Quarkus features:
- Fast startup time
- Low memory usage
- Build-time optimizations applied
| Component | Version |
|---|---|
| Bazel | 7.x+ |
| Java | 21 |
| Quarkus | 3.20.1 |
We provide several example applications to help you get started with rules_quarkus:
A minimal "Supersonic Subatomic" REST API showing the basic setup.
- Location:
examples/hello-world/ - Build:
bazel build //examples/hello-world:hello-world - Run:
./bazel-bin/examples/hello-world/hello-world
A comprehensive example demonstrating multi-tier extensions (REST, Jackson, Mutiny, Health, and Metrics).
- Location:
examples/demo-extensions/ - Build:
bazel build //examples/demo-extensions:demo-extensions - Run:
./bazel-bin/examples/demo-extensions/demo-extensions
Main macro for building Quarkus applications.
Parameters:
name: Application name (Required)srcs: Java source filesresources: Application resources (application.properties, etc.)deps: Regular dependencies (non-Quarkus libraries)runtime_extensions: Quarkus runtime extension modulesdeployment_extensions: Quarkus deployment modulesmain_class: Required. Set to your@QuarkusMainclass or the main class frompom.xml. Use"io.quarkus.runner.GeneratedMain"for standard applications.jvm_flags: JVM flags for running the application
Creates a library that can be used as a dependency for Quarkus applications.
Parameters:
name: Library namesrcs: Java source filesresources: Resourcesdeps: Dependenciesextensions: Quarkus extensions used by this library
- Architecting Deterministic Quarkus Builds: Native Support for Bazel β An in-depth look at the architecture and motivation behind
rules_quarkus. - Deep Dive: Taming the Quarkus ClassLoader for Hermetic Bazel Builds β The technical journey of solving ClassLoader challenges and Quarkus Issue #52915.
We welcome contributions! Please see CONTRIBUTING.md for guidelines on:
- Setting up the development environment
- Building and testing changes
- Submitting pull requests
- Reporting issues
Licensed under the Apache License, Version 2.0.
Created and maintained by:
Note: This project is a community-driven effort and is not officially affiliated with Red Hat or the Quarkus project.
This project is an evolution of the work originally started at tructxn/rule-quarkus.