Add support for compile-time input files in java_binary and java_library
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java
- Domain
- build-system
Research direction
Start at the java_binary and java_library rule definitions and trace how javacopts and input files reach the Java compiler. Compare the requested behavior with the C++ rules' additional_linker_inputs and user_link_flags, then verify that compile-time files and location expansion work under processwrapper sandboxing.
Written by the indexing model from the issue text.
Description
Description of the feature request:
Introduce a new attribute, tentatively named java_compiler_inputs, that would specifically hold references to compile-time input files. Additionally, provide support for expanding these file paths using $(location) or similar mechanisms, either within the existing javacopts attribute or a potentially new, toolchain-flag-specific attribute.
Example: Code snippet
java_library(
name = "dummy_library",
srcs = ["src/abc.java"],
java_compiler_inputs = ["compile.properties"],
javacopts = [
"-properties",
"$(location //:compile.properties)",
],
)
Which category does this issue belong to?
java rules
What underlying problem are you trying to solve with this feature?
I am working with a custom Java toolchain (specifically, ECJ https://github.com/salesforce/bazel-jdt-java-toolchain) that supports compile-time options like -properties to consume configuration files during compilation. Currently, there is no dedicated way to provide such files to the Java compiler within Bazel's Java rules. Including these files in the srcs attribute works in some sandbox environments but leads to failures with the processwrapper sandbox.
This feature would improve flexibility when using custom Java toolchains and ensure compatibility across different sandboxing strategies within Bazel. It would be valuable to draw parallels with a similar mechanism already present in Bazel's C++ rules for linker inputs (additional_linker_inputs and user_link_flags).
Which operating system are you running Bazel on?
RHEL7
What is the output of bazel info release?
7.0.2
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 HEAD ?
No response
Have you found anything relevant by searching the web?
Discussion on providing -properties file, no answers: https://github.com/salesforce/bazel-jdt-java-toolchain/discussions/19
Any other information, logs, or outputs that you want to share?
[Sandbox Error]: with processwrapper sandbox
exec env - \
LC_CTYPE=en_US.UTF-8 \
PATH=/bin:/usr/bin:/usr/local/bin \
/usr/lib/jvm/java-17/bin/java --module-path external/ecj/ecj.jar -jar external/bazel_jdt_java_toolchain/compiler/export/JdtJavaBuilder_deploy.jar @bazel-out/k8-opt/bin/bin-SystemLoggerApi-class.jar-0.params @bazel-out/k8-opt/bin/dummy_library-class.jar-1.params)
# Configuration: b958e1a85833ddcf110c5efdbae2648181c90445ef232e2d460d4a581e0c3ee6
# Execution platform: //:linux_gcc_x86
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
properties file compile.properties does not exist
- Dominant language
- Starlark
- Stars
- 103
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bazelbuild/rules_java
-
P4
Difficulty 4/5 3-5 days Newbie friendliness 55/100
bazelbuild/rules_java#360 · 4 comments · 2 reactions ·
-
P4
Difficulty 5/5 Over a week Newbie friendliness 35/100
bazelbuild/rules_java#354 · 8 comments ·
-
P3 question
Difficulty 3/5 1-2 days Newbie friendliness 45/100
bazelbuild/rules_java#339 · 1 comment ·
-
P3
Difficulty 4/5 3-5 days Newbie friendliness 35/100
bazelbuild/rules_java#325 · 8 comments ·
-
P4
Difficulty 4/5 3-5 days Newbie friendliness 35/100
bazelbuild/rules_java#316 · 2 reactions ·
All issues in bazelbuild/rules_java
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
package-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oSoWoSo/vOid_Community_repOsitory#147 · 1 comment ·
-
Builders
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100