【发布时间】:2019-07-04 19:57:26
【问题描述】:
尝试使用来自通过http_archive 导入的外部包中的build_file 中的目标,该外部包具有通过workspace_file 属性在外部包工作区中定义的依赖项失败。我在 Debian 测试中使用 Bazel 0.27.0。
该文档仅讨论了在提供的build_file 中引用目标,但我找不到任何信息如何在提供的build_file 中引用在提供的workspace_file 中定义的依赖项。
通常的@stringtemplate3//jar 语法失败,但我不知道如何包含对导入存档的引用,根据手册必须以@antlr3_runtimes 开头。
项目布局如下:
├── antlr.BUILD
├── antlr.WORKSPACE
├── BUILD
├── external_dependency
│ └── src
│ └── main
│ └── java
│ └── bazel
│ ├── BUILD
│ └── Hello.java
├── LICENSE
└── WORKSPACE
WORKSPACE 定义如下所示:
workspace(name="bazel")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "antlr3_runtimes",
sha256 = "d4f7d3c38c5523f8009ff37528e5797c81adb454be6acc9af507cfcb41f2016f",
strip_prefix = "antlr3-master",
urls = ["https://github.com/ibre5041/antlr3/archive/master.tar.gz"],
build_file = "@//:antlr.BUILD",
workspace_file = "@//:antlr.WORKSPACE",
)
似乎提供的workspace_file 甚至没有被分析。尝试解析自定义构建文件中的依赖项时,构建已经失败。
可以在此处找到重现:https://github.com/marcohu/bazel
bazel build //... 显示此错误消息:
ERROR: /home/user/.cache/bazel/_bazel_user/64492308e78c9898c41f12c18dd29b63/external/antlr3_runtimes/BUILD.bazel:43:1: no such package '@stringtemplate3//jar': The repository '@stringtemplate3' could not be resolved and referenced by '@antlr3_runtimes//:antlr3_tool'
ERROR: Analysis of target '//external_dependency/src/main/java/bazel:hello' failed; build aborted: no such package '@stringtemplate3//jar': The repository '@stringtemplate3' could not be resolved
我在 Bazel 问题跟踪器中报告了此问题,但被拒绝并提示在此处发布。
这个用例是不可能的吗?还是我语法错误?
【问题讨论】:
标签: bazel