bazel - 为第三方依赖创建 Bazel distdir
问题描述
我在一个在气隙环境中使用 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 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
文件夹中。
推荐阅读
- angular - 使用外部测试套件的角度应用程序的代码覆盖率
- windows - 批处理/MS-Windows-CMD:在 FOR 循环中递增的数字不递增
- node.js - GH Action 要求在 npm install 上进行身份验证
- sql - 创建仅返回行数的存储过程
- c++ - c ++中的链接错误(多个cpp文件)
- python - 为什么我的逻辑回归只产生一个类?
- python - 消息:过时的元素引用:元素未附加到页面文档 - Web Table Python
- node.js - 想要在 iOS 中从 react-native-track-payer 播放远程 url
- javascript - 计算星期几是 JS 与 Sakamoto、Wang、Schwerdtfeger
- sql - 为什么使用 presto 选择不同的值符合 prestosql 的隐式转换