【问题标题】:Creating a Bazel distdir for third-party dependencies为第三方依赖创建 Bazel distdir
【发布时间】:2020-07-16 22:29:37
【问题描述】:

我在一个在气隙环境中使用 SpringBoot 和 JUnit 的代码库上使用 Bazel。为了获取所有第三方依赖项,我需要运行以下命令:

bazel fetch '@bazel_tools//tools/build_defs/repo:*'
bazel fetch '@rules_java//java:*'
bazel fetch '@rules_cc//cc:*'
bazel fetch @local_config_platform//...
bazel fetch @local_config_sh//...
bazel fetch @maven//...
bazel fetch @org_opentest4j_opentest4j//jar:jar
bazel fetch @org_junit_jupiter_junit_jupiter_params//jar:jar
bazel fetch @org_junit_jupiter_junit_jupiter_engine//jar:jar
bazel fetch @org_junit_platform_junit_platform_console//jar:jar
bazel fetch @org_junit_platform_junit_platform_engine//jar:jar
bazel fetch @org_junit_platform_junit_platform_commons//jar:jar
bazel fetch @org_junit_platform_junit_platform_suite_api//jar:jar
bazel fetch @org_junit_platform_junit_platform_launcher//jar:jar
bazel fetch @org_apiguardian_apiguardian_api//jar:jar
bazel fetch @remote_coverage_tools//:coverage_report_generator
bazel fetch @remotejdk11_linux//:jdk

如何使这些依赖项在气隙环境中可用(我无法从 Internet 下载内容)? Bazel 是否有类似https://docs.bazel.build/versions/master/guide.html#running-bazel-in-an-airgapped-environment 的命令为第三方依赖项创建下载缓存?换句话说,Bazel 可以填充一个可以与其他机器共享并通过--distdir 使用的目录吗?还有其他方法可以共享 Bazel 的下载缓存吗?

【问题讨论】:

    标签: bazel


    【解决方案1】:

    也许bazel sync 可以在这里提供帮助。通过这个命令,你可以创建一个解析的文件(例如resolved.bzl

    bazel sync --experimental_repository_resolved_file=resolved.bzl
    

    此文件是一个 .json 文件。类似这样的内容:

    "repositories": [
        {
            "rule_class": "@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
            "attributes": {
                "url": "",
                "urls": [
                    "https://github.com/embree/embree/archive/v2.16.5.zip"
                ],
                "sha256": "9c4c0c385a7725946648578c1b58e887caa8b4a675a9356e76b9501d9e2e9e42",
                "netrc": "",
                "auth_patterns": {},
                "canonical_id": "",
                "strip_prefix": "embree-2.16.5",
                "type": "",
                "patches": [],
                "patch_tool": "",
                "patch_args": [
                    "-p0"
                ],
                "patch_cmds": [],
                "patch_cmds_win": [],
                "build_file": "//ThirdParty:embree.BUILD",
                "build_file_content": "",
                "workspace_file_content": "",
                "name": "embree"
            },
            "output_tree_hash": "b96d3a8db2ddd4bbc7ccde297a1d12e8be48c768bddde1ade53a4987861a1fe7"
        }
    ]
    

    您现在需要一个小助手工具(python 脚本 - 随便什么),它会访问已确定存储库中的每个 url/urls 并将其添加到您的 --distdir 文件夹中。

    【讨论】:

      猜你喜欢
      • 2022-08-16
      • 2011-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-05
      • 2018-12-09
      • 1970-01-01
      相关资源
      最近更新 更多