bazelbuild / bazelbuild/bazel

Handle RUNFILES_DIR and/or RUNFILES_MANIFEST_FILE in java_stub_template.txt

Open
#20,465 2 comments 1 reaction 0 assignees View on GitHub
P2 team-Rules-Java type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

The current implementation of `java_stub_template.txt`, used in `java_binary`, requires `JAVA_RUNFILES` to be present in the environment:

https://github.com/bazelbuild/bazel/blob/492ee4c91b507bc07f63da1bafa1696cbcf75bd2/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L159-L187

At the very least, it should also support the newer `RUNFILES_DIR` variable.

Additionally, the script could also gracefully handle having `RUNFILES_MANIFEST_FILE` in the env over `RUNFILES_DIR` or `JAVA_RUNFILES`.

### Which category does this issue belong to?

Java Rules

### What underlying problem are you trying to solve with this feature?

_No response_

### Which operating system are you running Bazel on?

Darwin

### What is the output of `bazel info release`?

release 6.4.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

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

Issue was highlighed while trying to solve https://github.com/bazel-contrib/rules_jvm/issues/211 through https://github.com/bazel-contrib/rules_jvm/pull/224.

More context on Bazel Slack: https://bazelbuild.slack.com/archives/C01HMGN77Q8/p1701887957242259

Contributor guide

Open the contributing guide

Research direction

Start with src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt around lines 159-187, the runfiles handling used by java_binary. Trace how JAVA_RUNFILES is currently read, then verify the desired precedence among RUNFILES_MANIFEST_FILE, RUNFILES_DIR, and JAVA_RUNFILES. Done means java_binary handles the newer runfiles variables, including manifest-file environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, shell
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.