Skip to content

Allow setting target_compatible_with and exec_compatible_with in calls to local_java_runtime #16497

@tshaynik

Description

@tshaynik

Description of the feature request:

When defining a local custom java toolchain with local_java_runtime, it is useful to be able to set constraints, using the target_compatible_with and exec_compatible_with arguments to native.toolchain. It would be useful to be able to provide those arguments directly to the local_java_runtime function, and have them be passed on to the invocation of native.toolchain.

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

In [rules_nixpkgs](https://github.com/tweag/rules_nixpkgs], we define a custom java toolchain, using a JDK from nixpkgs. We want to be able to set constraints on the toolchain, such as confirming that nix is available on the $PATH. We currently are using modified versions of local_java_repository.bzl and default_java_toolchain.bzl to add these arguments (and invoking them here), but it seems like it would be simple to expose those arguments directly in the Bazel codebase with out

Which operating system are you running Bazel on?

NixOS

What is the output of bazel info release?

release 6.0.0-pre.20220720.3- (@Non-Git)

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

Nix (from nixpkgs)

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

git@github.com:tshaynik/bazel.git
10d352bfed38ba066fbe87449f9d8d7686e139ff
09d958c3c86486e88ec9242ceb2ca08c277ff025

Have you found anything relevant by searching the web?

No.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)area-java-toolchainsjavabase, java_toolchain flags, JDK selection, java_toolchain rules, java_tools repositoryteam-Rules-JavaIssues for Java rulestype: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions