salesforce / rules_spring

Bazel rule for building Spring Boot apps as a deployable jar
BSD 3-Clause "New" or "Revised" License
228 stars 49 forks source link

SpringBoot rule should pull through deps and runtime_deps from java_library #31

Closed plaird closed 3 years ago

plaird commented 4 years ago

Given my base lib definition here:

java_library(
    name = "base_lib",
    srcs = glob(["src/main/java/**/*.java"]),
    resources = glob(["src/main/resources/**"]),
    deps = deps,
    runtime_deps = runtime_deps,
)

I have to construct the deps attribute for my springboot rule invocation like this:

springboot(
    name = "test-service",
    boot_app_class = "com.salesforce.services.test.TestServiceMain",
    java_library = ":base_lib",
    deps = deps + runtime_deps,
)

I shouldn't have to provide the deps or runtime_deps in the deps attribute, the rule should do that automatically.

yishanhe commented 4 years ago

should the springboot rule also exposes only runtime_deps instead of deps?

plaird commented 4 years ago

@yishanhe are you consuming the output of springboot rule somehow in other java_* rules? for us, the springboot rule is always a terminal node in the dependency graph, aside from docker rules. Since the springboot rule outputs a self-contained jar with all the dependencies contained within, I don't think there is a use case where it needs to expose deps or runtime_deps to downstream rules?

yishanhe commented 3 years ago

@plaird , Thank you for your explanation, and it is great to see this one gets improved.

A follow-up question, would it be clear if we put the deps in this way

java_library(
    name = "helloworld_lib",
    srcs = glob(["src/main/java/**/*.java"]),
    resources = glob(["src/main/resources/**"]),
    deps = lib_deps,
    runtime_deps = springboot_deps,
)

springboot(
    name = "helloworld",
    boot_app_class = "com.sample.SampleMain",
    java_library = ":helloworld_lib",
    # NO DEPS NEED TO BE DECLARED HERE
)

Thanks

plaird commented 3 years ago

Yes, I can add the comment to the example, that will make it more clear. Thanks for the feedback.