Quarkus: Support and example for using bazel, preferrably with java_image

Created on 27 Aug 2019  路  8Comments  路  Source: quarkusio/quarkus

Description
Tried below config

java_library(
    name = "lib",
    srcs = glob(["**/*.java"]),
    resources = glob(["resources/application.properties"]),
    visibility = ["//visibility:public"],
    deps = [
        "//:lombok",
        "@maven//:io_quarkus_quarkus_jackson",
        "@maven//:io_quarkus_quarkus_rest_client",
        "@maven//:io_quarkus_quarkus_resteasy_jackson",
        "@maven//:io_quarkus_quarkus_smallrye_health",
        "@maven//:javax_inject_javax_inject",
        "@maven//:javax_enterprise_cdi_api_2_0_SP1",
        "@maven//:org_eclipse_microprofile_config_microprofile_config_api",
        "@maven//:org_eclipse_microprofile_rest_client_microprofile_rest_client_api",
        "@maven//:org_jboss_spec_javax_ws_rs_jboss_jaxrs_api_2_1_spec",
        "@maven//:org_slf4j_slf4j_api",
        "@maven//:com_fasterxml_jackson_core_jackson_annotations",
        "@maven//:com_fasterxml_jackson_core_jackson_core",
        "@maven//:com_fasterxml_jackson_core_jackson_databind",
    ],
)

load("@io_bazel_rules_docker//java:image.bzl", "java_image")

java_image(
    name = "docker",
    runtime_deps = [":lib"],
)

But its missing a target to run. Can't figure out what/how pass the correct target.

May be dependent on https://github.com/quarkusio/quarkus/issues/2143

kinenhancement kinquestion

Most helpful comment

We'll see if the Main class thing actually happens.

All 8 comments

I don't know anything about Bazel (and I assume I'm not the only one), but I strongly suspect this can't work.
Basically for Maven and Gradle Quarkus has a plugin that creates the final artifact - no such plugin exists for Bazel.
Now if/when Quarkus can be run from a simple public static void main, something like this would maybe work

Do we use any annotationProcessor to generate the main class?

Quarkus does not use annotation processors. All the magic is done at a post compile phase.

So to support Bazel we would need a plugin like the Maven and Gradle plugin Quarkus provides.

Bazel doesn't have as such a plugin mechanism, however its more of a generic rule which you can define. A rule can be a shell script, java jar, or any binary etc. Basically, if I can get a jar from maven central, and can run java -jar /my/code/src/dir and can generate the Main class, we can make bazel work with it :)

Or as stated earlier, having the main class in code would be simplest :)

We'll see if the Main class thing actually happens.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you!
We are doing this automatically to ensure out-of-date issues does not stay around indefinitely.
If you believe this issue is still relevant please put a comment on it on why and if it truly needs to stay request or add 'pinned' label.

I'm closing this one for now. If at some point you get it to work, we will be happy to host the related documentation.

Was this page helpful?
0 / 5 - 0 ratings