agentsclimarketplace

Quarkus native

Skill kinhluan/rules-quarkus-skills/.agent-skills/quarkus-native

πŸ€– Complete AI expert ecosystem for Modern Java, Quarkus & Bazel development β˜•οΈβš‘οΈ Coverage for Vert.x, GraalVM, Maven/Gradle migration, and more πŸš€

Install
npx -y skills add kinhluan/rules-quarkus-skills --skill quarkus-native

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Deep expertise in Quarkus Native Image builds, GraalVM integration, reflection configuration, and Profile-Guided Optimization. Use for native compilation questions.

SKILL.md

11.8 KB, as published. Nobody here has run it

quarkus-native

Keyword: quarkus-native | Platforms: gemini,claude,codex

Quarkus Native Image Expert Skill - Specialized in building, optimizing, and troubleshooting native executables for Quarkus applications.

Core Mandates

  • Closed-World Awareness: All classes, methods, and resources must be known at build time.
  • Reflection Explicit: Register all reflection usage via @RegisterForReflection or reflection-config.json.
  • Resource Registration: All runtime resources must be declared in resource-config.json.
  • Build-Time Initialization: Prefer build-time initialization for faster startup; use runtime init only for side-effect classes.
  • Test in Native Mode: Always run @QuarkusIntegrationTest against the native binary before production.

Quick Start: Native Build

Maven

# Build native executable
./mvnw package -Dnative

# Build in container (recommended for CI)
./mvnw package -Dnative -Dquarkus.native.container-build=true

# Build and run integration tests
./mvnw verify -Pnative

Gradle

# Build native executable
./gradlew build -Dquarkus.package.type=native

# Build in container
./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true

Bazel (rules_quarkus)

# Using rules_quarkus
bazel build //:myapp_native

# With custom builder image
bazel build //:myapp_native \
  --@rules_quarkus//native:builder_image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21

Quarkus Native Configuration

Essential Properties

# === Build Type ===
quarkus.package.type=native

# === Container Build (Recommended) ===
quarkus.native.container-build=true
quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21

# === Memory ===
quarkus.native.native-image-xmx=8g

# === Debugging ===
quarkus.native.additional-build-args=-H:+ReportExceptionStackTraces

# === Reports ===
quarkus.native.enable-reports=true
# Generates: target/reports/call_tree_*.txt, target/reports/reachable_methods.txt

Profile-Specific Native Config

# application.properties
%prod.quarkus.package.type=native
%prod.quarkus.native.container-build=true
%prod.quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21

# Development (JVM mode for fast startup)
%dev.quarkus.package.type=jar

# Test (native for integration tests)
%test.quarkus.package.type=native

Builder Images

ImageJDKSizeUse Case
ubi-quarkus-mandrel-builder-image:jdk-2121MediumGeneral purpose
ubi-quarkus-graalvmce-builder-image:jdk-2121LargeGraalVM CE with all features
ubi-quarkus-mandrel-builder-image:jdk-21.0.2.0-Final-java2121MediumSpecific Mandrel version

Reflection Configuration

@RegisterForReflection (Recommended)

// Register a single class
@RegisterForReflection
public class UserDto {
    private String name;
    private String email;
    // getters/setters
}

// Register with specific targets
@RegisterForReflection(targets = { UserDto.class, OrderDto.class })
public class ReflectionConfig {
}

// Register all fields and methods
@RegisterForReflection(fields = false, methods = true)
public class ApiResponse {
    public String status;
    public Object data;
}

reflection-config.json

[
  {
    "name": "com.example.UserDto",
    "allDeclaredConstructors": true,
    "allPublicConstructors": true,
    "allDeclaredMethods": true,
    "allPublicMethods": true,
    "allDeclaredFields": true,
    "allPublicFields": true
  },
  {
    "name": "com.example.OrderDto",
    "methods": [
      { "name": "getId", "parameterTypes": [] },
      { "name": "setId", "parameterTypes": ["java.lang.Long"] }
    ],
    "fields": [
      { "name": "status" }
    ]
  }
]

Native Image Agent (Auto-Generate)

# Run tests with agent to auto-generate reflection config
./mvnw test -Dquarkus.native.agent.enabled=true

# Or run the application with agent
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image \
  -jar target/quarkus-app/quarkus-run.jar

# Merge with existing config
java -agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image \
  -jar target/quarkus-app/quarkus-run.jar

Resource Configuration

resource-config.json

{
  "resources": {
    "includes": [
      { "pattern": "\\Qapplication.properties\\E" },
      { "pattern": "\\Qdb/migration/.*\\E" },
      { "pattern": "\\QMETA-INF/.*\\E" },
      { "pattern": "\\Qtemplates/.*\\E" }
    ],
    "excludes": [
      { "pattern": "\\Q*.test\\E" }
    ]
  },
  "bundles": [
    { "name": "messages" },
    { "name": "ValidationMessages" }
  ]
}

Quarkus Resource Registration

# Register resources in application.properties
quarkus.native.resources.includes=db/migration/.*,templates/.*
quarkus.native.resources.excludes=*.test,*.dev

Initialization Configuration

Build-Time vs Runtime Initialization

# application.properties
quarkus.native.additional-build-args=\
  --initialize-at-build-time=com.example.ConfigClass,\
  --initialize-at-run-time=com.example.NetworkClient,\
  --trace-class-initialization=com.example.*

Common Initialization Patterns

// Build-time initialization (fast startup)
@io.quarkus.runtime.annotations.RegisterForReflection
public class BuildTimeConfig {
    public static final String VERSION = "1.0.0";  // Initialized at build time
}

// Runtime initialization (for classes with side effects)
public class RuntimeConfig {
    static {
        // This runs at runtime, not build time
        System.loadLibrary("native-lib");
    }
}

Profile-Guided Optimization (PGO)

Step-by-Step PGO

# Step 1: Build instrumented native binary
./mvnw package -Dnative \
  -Dquarkus.native.additional-build-args=--pgo-instrument

# Step 2: Run instrumented binary to collect profile data
./target/myapp-1.0.0-SNAPSHOT-runner
# Exercise typical workloads: API calls, database operations, etc.
# This generates: default.iprof

# Step 3: Build optimized binary with profile
./mvnw package -Dnative \
  -Dquarkus.native.additional-build-args=--pgo=default.iprof

PGO with Custom Profile Name

# Build instrumented with custom profile name
./mvnw package -Dnative \
  -Dquarkus.native.additional-build-args=--pgo-instrument=myapp.iprof

# Run and collect profile
./target/myapp-1.0.0-SNAPSHOT-runner

# Build optimized
./mvnw package -Dnative \
  -Dquarkus.native.additional-build-args=--pgo=myapp.iprof

Native Image Testing

@QuarkusIntegrationTest

@QuarkusIntegrationTest
class NativeUserResourceIT {

    @Test
    void shouldListUsers() {
        given()
            .when().get("/api/users")
            .then()
            .statusCode(200);
    }

    @Test
    void shouldCreateUser() {
        given()
            .contentType(ContentType.JSON)
            .body("{\"name\": \"Alice\", \"email\": \"[email protected]\"}")
            .when().post("/api/users")
            .then()
            .statusCode(201);
    }
}

Conditional Native Testing

@QuarkusTest
class UserResourceTest {

    @Test
    @DisabledOnNativeImage
    void shouldTestDevOnlyFeature() {
        // Only runs in JVM mode
    }

    @Test
    @EnabledOnNativeImage
    void shouldTestNativeOnlyFeature() {
        // Only runs in native mode
    }
}

Troubleshooting Decision Tree

Native build failed?
  β”œβ”€β”€ "ClassNotFoundException" at runtime
  β”‚     └── Missing reflection config
  β”‚         β”œβ”€β”€ Add @RegisterForReflection to the class
  β”‚         β”œβ”€β”€ Add to reflection-config.json
  β”‚         └── Run with native-image agent
  β”œβ”€β”€ "NoSuchMethodException" at runtime
  β”‚     └── Missing method in reflection config
  β”‚         └── Add method to reflection-config.json
  β”œβ”€β”€ "MissingResourceException"
  β”‚     └── Resource not included in native image
  β”‚         β”œβ”€β”€ Add to resource-config.json
  β”‚         └── Use quarkus.native.resources.includes
  β”œβ”€β”€ "UnsupportedFeatureError"
  β”‚     └── Using unsupported JVM feature
  β”‚         β”œβ”€β”€ Check GraalVM limitations
  β”‚         └── Use --report-unsupported-elements-at-runtime
  β”œβ”€β”€ "OutOfMemoryError" during build
  β”‚     └── Increase build memory
  β”‚         └── quarkus.native.native-image-xmx=8g (or 12g)
  β”œβ”€β”€ Build timeout
  β”‚     └── Increase timeout or use more powerful machine
  β”‚         └── quarkus.native.additional-build-args=--timeout=600
  └── "Image build request failed"
        └── Docker/container issues
            └── Check Docker daemon, pull builder image manually

Common Errors & Fixes

ErrorCauseFix
ClassNotFoundExceptionMissing reflection configAdd @RegisterForReflection or reflect-config.json
NoSuchMethodExceptionMethod not in reflection configAdd method to reflect-config.json
MissingResourceExceptionResource not includedAdd to resource-config.json
IllegalArgumentException: ProxyMissing proxy configAdd to proxy-config.json
OutOfMemoryErrorInsufficient build memoryIncrease quarkus.native.native-image-xmx
UnsupportedFeatureErrorUnsafe/JNI usageUse --report-unsupported-elements-at-runtime
Image build request failedDocker not runningStart Docker daemon
Build timeoutComplex applicationIncrease timeout, use more memory

Optimization Strategies

Reducing Image Size

# Remove unused beans
quarkus.native.remove-unused-beans=true

# Remove metadata for smaller image
quarkus.native.enable-reports=false

# Exclude unnecessary resources
quarkus.native.resources.excludes=*.md,*.txt

Improving Startup Time

# Use SerialGC for small heaps (default for native)
quarkus.native.additional-build-args=--gc=serial

# Or G1GC for larger heaps
quarkus.native.additional-build-args=--gc=G1

# Enable PGO for better performance
quarkus.native.additional-build-args=--pgo=default.iprof

Memory Tuning

# Set max heap for native image
quarkus.native.additional-build-args=-R:MaxHeapSize=256m

# Set initial heap
quarkus.native.additional-build-args=-R:MinHeapSize=64m

Bazel Native Build

BUILD.bazel for Native Image

load("@rules_quarkus//quarkus:defs.bzl", "quarkus_application")

quarkus_application(
    name = "myapp_native",
    srcs = glob(["src/main/java/**/*.java"]),
    resources = glob(["src/main/resources/**"]),
    deps = [
        "//common/utils",
        "@maven//:io_quarkus_quarkus_core",
        "@maven//:io_quarkus_quarkus_rest",
    ],
    native = True,
    native_image_xmx = "8g",
    additional_build_args = [
        "-H:+ReportExceptionStackTraces",
        "--initialize-at-build-time=com.example.Config",
    ],
)

References

Skill Interoperability

The quarkus-native skill specializes in:

  • graalvm-expert πŸš€: Core GraalVM Native Image knowledge.
  • quarkus-expert ⚑: Quarkus-specific native build configuration.
  • rules-quarkus πŸ”§: Bazel integration for native builds.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.