我正在努力将我们的项目迁移到 Bazel。
工作空间
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.10"
RULES_JVM_EXTERNAL_SHA = "1bbf2e48d07686707dd85357e9a94da775e1dbd7c464272b3664283c9c716d26"
http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "maven",
artifacts = [
"com.foo:bar:1.0.0-SNAPSHOT"
"org.apache.commons:commons-lang3:3.9",
],
repositories = [
"https://our-maven-repo",
],
resolve_timeout = 200,
fail_on_missing_checksum = False,
fetch_sources = True
)
建造
java_library(
name = "our-name",
srcs = glob([
"src/main/java/**/*.java"
]),
resources = glob([
"src/main/resources/**",
]),
deps = [
"@maven//:com.foo_bar",
"@maven//:org.apache.commons_commons-lang3"
],
)
当我运行时:
PS> bazel fetch //:our-name
输出
INFO: Call stack for the definition of repository 'maven' which is a coursier_fetch (rule definition at C:/users/name/_bazel_name/73nyktky/external/rules_jvm_external/coursier.bzl:620:18):
- C:/users/name/_bazel_name/73nyktky/external/rules_jvm_external/defs.bzl:89:5
- C:/project/WORKSPACE:19:1
INFO: Repository 'maven' used the following cache hits instead of downloading the corresponding file.
* Hash '8f35f92fb8e021f96b3aa8145c66c3b2e29295baabb28ff50569e613438afcbd' for https://github.com/coursier/coursier/releases/download/v2.0.0-RC3-4/coursier.jar
If the definition of 'maven' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'maven':
Error while obtaining the sha256 checksum of v1/https/our-repo/prod/org/apache/commons/commons-lang3/3.9/commons-lang3-3.9.jar: java.io.IOException: ERROR: src/main/native/windows/process.cc(199): CreateProcessW("python" C:/users/name/_bazel_name/73nyktky/external/bazel_tools/tools/build_defs/hash/sha256.py C:/users/name/_bazel_name/73nyktky/external/maven/v1/https/ourrepo/prod/org/apache/commons/commons-lang3/3.9/commons-lang3-3.9.jar artifact.sha256): The system cannot find the file specified.
(error: 2)
ERROR: C:/project/BUILD:1:1: no such package '@maven//': Error while obtaining the sha256 checksum of v1/https/our-repo/prod/org/apache/commons/commons-lang3/3.9/commons-lang3-3.9.jar: java.io.IOException: ERROR: src/main/native/windows/process.cc(199): CreateProcessW("python" C:/users/name/_bazel_name/73nyktky/external/bazel_tools/tools/build_defs/hash/sha256.py C:/users/name/_bazel_name/73nyktky/external/maven/v1/https/ourrepo/prod/org/apache/commons/commons-lang3/3.9/commons-lang3-3.9.jar artifact.sha256): The system cannot find the file specified.
(error: 2) and referenced by '//:our-name'
ERROR: Evaluation of query "deps(//:our-name)" failed: errors were encountered while computing transitive closure
Loading: 0 packages loaded
org.apache.commons:commons-lang3:3.9 jar 确实可以下载,以及 sha1 和 md5 哈希。com.foo:bar:1.0.0-SNAPSHOT jar 不会被下载。sha1 和 md5 确实被下载了。
我认为我的问题是我们的 repo 没有任何 sha256 哈希可供下载,因此获取(或构建)失败并出现该错误。但是,当我查看实际的 rules_jvm_external https://github.com/bazelbuild/rules_jvm_external#checksum-verification时,似乎 sha256 不是强制性的?
关于我做错了什么的任何想法?
Bazel 1.1.0 Windows 10 企业版,版本 1803,操作系统内部版本 17134.1069