Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--disable-3rdparty-in-repo sometimes generates empty BUILD files for Kotlin deps #290

Open
pbsf opened this issue Mar 27, 2020 · 0 comments

Comments

@pbsf
Copy link

pbsf commented Mar 27, 2020

I have the following dependencies.yaml:

options:
  buildHeader: [ "load(\"@io_bazel_rules_kotlin//kotlin:kotlin.bzl\", \"kt_jvm_import\")",
    "licenses([\"notice\"])" ]
  languages: [ "kotlin" ]
  resolverType: "coursier"
  resolvers:
    - id: "mavencentral"
      type: "default"
      url: https://repo.maven.apache.org/maven2/
  thirdPartyDirectory: "3rdparty"

dependencies:
  com.github.ajalt:
    clikt:
      lang: kotlin
      version: "2.3.0"

And the following WORKSPACE:

workspace(name = "project")

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

# ----------------------------------------------------------------------------
# Kotlin.

rules_kotlin_version = "legacy-1.3.0-rc4"
rules_kotlin_sha = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff"
http_archive(
    name = "io_bazel_rules_kotlin",
    urls = [
        "https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % rules_kotlin_version,
    ],
    strip_prefix = "rules_kotlin-%s" % rules_kotlin_version,
    sha256 = rules_kotlin_sha,
)

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")

kotlin_repositories()
kt_register_toolchains()

# ----------------------------------------------------------------------------
# Bazel-deps.

load("//3rdparty:workspace.bzl", "maven_dependencies")
maven_dependencies()

load("//3rdparty:target_file.bzl", "build_external_workspace")
build_external_workspace(name = "3rdparty")

I modified update_dependencies.sh to receive --disable-3rdparty-in-repo as a flag.

The following works:

./update_dependencies.sh
bazel build //3rdparty/com/github/ajalt:clikt

The following doesn't:

./update_dependencies.sh --disable-3rdparty-in-repo
bazel build @3rdparty//3rdparty/com/github/ajalt:clikt

Here is the error message:

ERROR: no such target '@3rdparty//3rdparty/com/github/ajalt:clikt': target 'clikt' not declared in package '3rdparty/com/github/ajalt' defined by /root/.cache/bazel/_bazel_root/a254c33c1cf4cabb64a59c0bfb96da7c/external/3rdparty/3rdparty/com/github/ajalt/BUILD

Here is the content of the generated BUILD file on the second attempt:

 $ cat  /root/.cache/bazel/_bazel_root/a254c33c1cf4cabb64a59c0bfb96da7c/external/3rdparty/3rdparty/com/github/ajalt/BUILD
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_import")
licenses(["notice"])

I did succeed importing some Kotlin dependencies disabling the 3rd party folders, but not this one, which is weird. Is the second command incorrect? I can create a repository that reproduces the issue if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant