0

这是我的工作区;

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


RULES_JVM_EXTERNAL_TAG = "4.0"
RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169"

http_archive(
    name = "maven",
    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("@maven//:defs.bzl", "maven_install")


maven_install(
    artifacts = [
        "com.fasterxml.jackson.core:jackson-databind:2.12.1",
        "org.apache.commons:commons-lang3:3.11"
    ],
    repositories = [
        "https://repo1.maven.org/maven2",
        "https://jcenter.bintray.com/"
    ],
);

这是我的第二个/构建

java_binary(
     name = "main",
     srcs = glob(["src/main/java/**/*.java"]),
     deps = [
             "//First:first",
     ],
     main_class = "com.test.MyMain",
);

这是我的第一个/构建

java_library(
    name = "first",
    srcs = glob(["src/main/java/**/*.java"]),
    deps = [
                "@maven//:com_fasterxml_jackson_core_jackson_databind",
            ],
    visibility =[ "//Second:__pkg__"],
);

做的时候

bazel build //Second:main

我明白了

ERROR: /Users/foobar/Documents/Main/First/BUILD:1:13: error loading package '@maven//': Unable to find package for @bazel_skylib//:bzl_library.bzl: The repository '@bazel_skylib' could not be resolved. and referenced by '//First:first'
ERROR: Analysis of target '//Second:main' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.078s
INFO: 0 processes.
4

1 回答 1

0

您需要将 Bazel Skylib 添加到您的工作区。按照此处的“工作区设置”说明:https ://github.com/bazelbuild/bazel-skylib/releases

于 2021-01-12T10:31:29.177 回答