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

Bazel 5: Rules_java needs to export the defs.bzl file to allow generating docs #14370

Open
tjoneslo opened this issue Dec 3, 2021 · 2 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-Java Issues for Java rules type: documentation (cleanup)

Comments

@tjoneslo
Copy link

tjoneslo commented Dec 3, 2021

Description of the problem / feature request:

With Bazel 5, the rules_java have been moved to the internal to Bazel itself. This has removed access to the rules java defs.bzl file. This in turn blocks our ability to generate our internal build documentation.

Feature requests: what underlying problem are you trying to solve with this feature?

When building the documentation for our project using Stardoc, we need to include all of the dependencies. Since we use rules_java in our project we need to include those. We use the bazel-skylib with the bzl_library to collect the .bzl files to provide to the stardoc rules with the references to generate the documentation.

Using the bzl_library to collect the rules_java results in the error:

ERROR: /Users/tjoneslo/Documents/workspace/java/BUILD.bazel:87:12: no such target '@rules_java//java:defs.bzl': target 'defs.bzl' not declared in package 'java'; however, a source file of this name exists. (Perhaps add 'exports_files(["defs.bzl"])' to java/BUILD?) defined by /private/var/tmp/_bazel_tjoneslo/36945587f23d21b910d2b6901d7e1f8e/external/rules_java/java/BUILD and referenced by '//java:rules-java-docs'

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

WORKSPACE:

workspace(name = "test_docs")

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

http_archive(
    name = "bazel_skylib",
    urls = [
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
    ],
    sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

BUILD.bazel

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
    name = "rules-java-docs",
    srcs = [
        "@rules_java//java:defs.bzl",
    ],
)

What operating system are you running Bazel on?

What's the output of bazel info release?

% bazel info release
INFO: Invocation ID: b9bb1040-1962-4f14-9fee-91d653c399f0
release 5.0.0rc2

Have you found anything relevant by searching the web?

Any other information, logs, or outputs that you want to share?

@Wyverald
Copy link
Member

Wyverald commented Dec 7, 2021

@comius thoughts?

@comius
Copy link
Contributor

comius commented Dec 15, 2021

With Bazel 5, the rules_java have been moved to the internal to Bazel itself. This has removed access to the rules java defs.bzl file. This in turn blocks our ability to generate our internal build documentation.

I'm not exactly sure what you're referring to. rules_java is still an external repository and it is imported by default via workspace prefix mechanism. The version of rules_java that is imported has not changed since 2019-07-03.

There is a "builtin" java_library implementation. But this does not change how rules_java are imported. So if you are loading a different version of rules_java in your WORKSPACE you should continue to do so.

I tested you reproduction with Bazel 4.2.2 and it results in the same error.

@comius comius added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged labels Dec 15, 2021
@ShreeM01 ShreeM01 added the team-Documentation Documentation improvements that cannot be directly linked to other team labels label Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-Java Issues for Java rules type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

5 participants