๐ Native Bazel rules for Quarkus using QuarkusBootstrap API. 3-layer hermetic builds with 5-Tier extensions (Core โ LangChain4j).
rules_quarkus โ Bazel Rules for Quarkus Applications
Bazel rules for building Quarkus applications with build-time augmentation support.
Overview
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.
Quick Start
Installation
Add the following to your MODULE.bazel:
bazeldep(name = "rulesquarkus", version = "0.1.0")
Add Quarkus dependencies
maven = useextension("@rulesjvm_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
],
)
Basic Usage
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//:jakartawsrsjakartawsrsapi", "@maven//:jakartaenterprisejakartaenterprisecdi_api", ],
# Quarkus runtime extensions runtime_extensions = [ "@maven//:ioquarkusquarkus_arc", "@maven//:ioquarkusquarkus_rest", "@maven//:ioquarkusquarkusvertxhttp", ],
# Quarkus deployment modules (for build-time processing) deployment_extensions = [ "@maven//:ioquarkusquarkusarcdeployment", "@maven//:ioquarkusquarkusrestdeployment", "@maven//:ioquarkusquarkusvertxhttp_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/hello
Supported Extensions
rules_quarkus supports a wide range of Quarkus extensions organized in 5 tiers:
Tier 1: Core (Essential)
| 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 |
Tier 2: Database (Reactive)
| Extension | Description | |-----------|-------------| |quarkus-reactive-oracle-client | Reactive Oracle database client |
| quarkus-reactive-mysql-client | Reactive MySQL database client |
| quarkus-redis-client | Redis client |
Tier 3: Messaging
| Extension | Description | |-----------|-------------| |quarkus-messaging-kafka | Apache Kafka messaging |
| quarkus-messaging-rabbitmq | RabbitMQ messaging |
| quarkus-grpc | gRPC services |
Tier 4: Observability
| Extension | Description | |-----------|-------------| |quarkus-micrometer-registry-prometheus | Prometheus metrics |
| quarkus-smallrye-health | Health checks |
Tier 5: Quarkiverse
| 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 |
Architecture
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. โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
Layer 1: Compile
Standard Java compilation using Bazel'sjava_library. Source files are compiled to bytecode with minimal processing.
Layer 2: Augment
Quarkus build-time augmentation using the official QuarkusBootstrap API:- Jandex bytecode indexing
- CDI proxy generation
- Configuration processing
- Extension discovery
- Optimized bytecode generation
Layer 3: Runtime
Executable application with fully processed Quarkus features:- Fast startup time
- Low memory usage
- Build-time optimizations applied
Requirements
| Component | Version | |-----------|---------| | Bazel | 7.x+ | | Java | 21 | | Quarkus | 3.20.1 |
Examples
We provide several example applications to help you get started with rules_quarkus:
๐ Hello World
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
๐๏ธ Demo Extensions Showcase
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
Macros and Rules
quarkus_application
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
quarkus_library
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
Resources
- 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.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines on:
- Setting up the development environment
- Building and testing changes
- Submitting pull requests
- Reporting issues
License
Licensed under the Apache License, Version 2.0.
Authors
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.