aspect-build / rules_js

High-performance Bazel rules for running Node.js tools and building JavaScript projects
https://docs.aspect.build/rules/aspect_rules_js
Apache License 2.0
310 stars 107 forks source link

[Bug]: Can't package the files in dist folder into jar package #1896

Open zacker330 opened 3 months ago

zacker330 commented 3 months ago

What happened?

I have a bazel project that include java code and react code.

I am going to include the react ui build result into my java project's resource folder while building.

BUILD.bazel in the package of react code

js_run_binary(
    name = "build",
    srcs = RUNTIME_DEPS,
    args = ["build"],
    mnemonic = "ViteBuild",

    out_dirs = ["dist"],
    tool = ":vite",
    visibility = ["//server:__subpackages__"],
)

BUILD.bazel in the package of java code. As the code shows it should package the contents of dist out_dirs.

java_binary(
    name = "app_lib",
    main_class = "codes.showme.server.Main",
    create_executable = False,
    resources = [
        # I am going to include the react ui dist conent into my java project's resource folder while building
        "//web-react-ui:build",
    ],
    runtime_deps = [
        ":lib",
    ],
)

But when I unpackage the java jar, the dist folder is empty.

Is there any way to package all contents into the jar file? Thank you.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 7.2.1

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_bazel_lib", version = "2.7.7") bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc4") bazel_dep(name = "aspect_rules_jest", version = "0.22.0-rc0") bazel_dep(name = "aspect_rules_js", version = "2.0.0-rc1") bazel_dep(name = "aspect_rules_swc", version = "2.0.0-rc0") bazel_dep(name = "aspect_rules_ts", version = "3.0.0-rc0") bazel_dep(name = "aspect_rules_rollup", version = "2.0.0-rc0") bazel_dep(name = "aspect_rules_webpack", version = "0.16.0-rc0") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "rules_nodejs", version = "6.1.1")

Language(s) and/or frameworks involved: Java & TypeScript

How to reproduce

No response

Any other information?

No response