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 : java_library no longer has resource_jars attribute #14374

Closed
tjoneslo opened this issue Dec 3, 2021 · 4 comments
Closed

Bazel 5 : java_library no longer has resource_jars attribute #14374

tjoneslo opened this issue Dec 3, 2021 · 4 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-Java Issues for Java rules type: support / not a bug (process)

Comments

@tjoneslo
Copy link

tjoneslo commented Dec 3, 2021

Description of the problem / feature request:

In previous versions of Bazel, the java_library rule had a resource_jars attribute with allowed adding resource files into the constructed jar. This feature is due to be removed in Bazel 6, and is disabled by default in Bazel 5. However there is no way to enable the use of the resource_jars attribute in Bazel 5rc2

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

Our older rules still use java_library with the resource_jars attribute. Migration to the new version requires updating the rules using this attribute and, in some cases, modifying other rules as well. We were hoping that the transition to Bazel 5 could be completed before having to re-write many rules in our build system.

Simply replacing the resource_jars with the runtime_deps (or deps) to add the files into the final jar is the rule producing the dependency must return a JavaInfo. So in some cases the rule collecting the files didn't need to be Java specific. But now it does.

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

WORKSPACE:

workspace(name="test_resource_jars")

BUILD.bazel

load("@rules_java//java:defs.bzl", "java_library")
java_library(
    name = "test_jar",
    resource_jars = [":BUILD.bazel"]
)

% bazel build --incompatible_disallow_resource_jars=false //...
INFO: Invocation ID: 9073985b-f840-48d3-a69c-41c0ead0ebad
ERROR: /Users/tjoneslo/Documents/workspace/apple_federation/tests/resource_jars/BUILD.bazel:2:13: //:test_jar: no such attribute 'resource_jars' in 'java_library' rule
ERROR: error loading package '': Package '' contains errors

What's the output of bazel info release?

% bazel info release
release 5.0.0rc2

@Wyverald
Copy link
Member

Wyverald commented Dec 7, 2021

@comius any thoughts?

@comius
Copy link
Contributor

comius commented Dec 15, 2021

Please follow the instructions on #13221

The issue explains the migration.
The migration can be extended using flags.

@comius comius added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: support / not a bug (process) and removed type: support / not a bug (process) untriaged labels Dec 15, 2021
@github-actions
Copy link

github-actions bot commented Jun 9, 2023

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 9, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 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) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-Java Issues for Java rules type: support / not a bug (process)
Projects
None yet
Development

No branches or pull requests

4 participants