使用 bazel 如何使用单个 jar 文件创建 tar 文件

With bazel how to create a tar files with individual jar files

我想为 java 项目 X 创建一个 tar 文件,该文件依赖于库 Y 和 Z,其结构类似于

bin/runx (from src/main/scripts)
lib/x.jar (the compiled contents of src/main/java)
lib/y.jar (a maven_jar X depends on)
lib/z.jar (a maven_jar X depends on) 
conf/x (from src/main/resources/conf/x)

任何内置的 bazel 规则是否支持此功能?这是我需要用 skylark 或 bash 写下自己的东西吗?

我设法让它以一种非常糟糕的方式工作。

https://github.com/yschimke/oksocial/blob/bazel/BUILD

我找不到扩展目标所需的 jar 文件的好方法。

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

pkg_tar(
    name = "bundle-libs",
    package_dir = "lib",
    files = [
      '//src/main/java/com/baulsupp/oksocial',
      '@com_squareup_okhttp3_okhttp//jar',
      '@com_squareup_okhttp3_logging_interceptor//jar',
      '@com_squareup_okio_okio//jar',
      '@com_fasterxml_jackson_core_jackson_databind//jar',
      '@com_fasterxml_jackson_dataformat_jackson_dataformat_yaml//jar',
      '@com_twitter_joauth//jar',
      '@com_google_oauth_client_google_oauth_client_jetty//jar',
      '@com_google_guava_guava//jar',
      '@org_mortbay_jetty_jetty//jar',
      '@com_github_mrmike_ok2curl//jar',
      '@commons_cli_commons_cli//jar',
      '@commons_lang_commons_lang//jar',
      '@commons_io_commons_io//jar',
      '@org_slf4j_slf4j_jcl//jar',
      '@io_airlift_airline//jar',
      '@javax_inject_javax_inject//jar',
    ],
    mode = "0644",
)

pkg_tar(
    name = "bundle-alpn",
    package_dir = "alpn",
    files = ["@alpn_boot//jar"],
    mode = "0644",
)

pkg_tar(
    name = "bundle-bin",
    package_dir = "bin",
    files = glob(["src/main/scripts/**"]),
    mode = "0755",
)

pkg_tar(
    name = "oksocial-bundle",
    extension = "tgz",
    deps = [
        ":bundle-bin",
        ":bundle-libs",
        ":bundle-alpn",
    ],
)

pkg_tar应该支持,见http://bazel.io/docs/be/pkg.html#pkg_tar