为第三方依赖项创建Bazel distdir
我在一个代码库上使用Bazel,该代码库在一个空的环境中使用SpringBoot和JUnit。以下是获取所有第三方依赖项所需运行的命令:为第三方依赖项创建Bazel distdir,bazel,Bazel,我在一个代码库上使用Bazel,该代码库在一个空的环境中使用SpringBoot和JUnit。以下是获取所有第三方依赖项所需运行的命令: 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
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是否有为第三方依赖项创建下载缓存的命令,类似于?换句话说,Bazel是否可以填充一个目录,该目录可以与其他机器共享,并通过那里的
--distdir
使用?还有其他方法可以共享Bazel的下载缓存吗?也许Bazel sync
可以在这里提供帮助。通过此命令,您可以创建已解析的文件(例如,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
/url
,并将其添加到--distdir
文件夹中
"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"
}
]