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

Set java on remote JDKs #133

Merged
merged 1 commit into from
Oct 6, 2023
Merged

Conversation

fmeum
Copy link
Contributor

@fmeum fmeum commented Sep 22, 2023

If the java attribute on java_runtime isn't set, Bazel guesses it based on the host platform, which can be different from the execution platform.

https://github.com/bazelbuild/bazel/blob/04a05677e4714434ec196c45a4ccbd8e0ef2f0ff/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java#L46

Work towards bazelbuild/bazel#19587

@fmeum fmeum requested review from comius and a team as code owners September 22, 2023 06:18
@fmeum
Copy link
Contributor Author

fmeum commented Sep 22, 2023

CC @tjgq @UebelAndre

cushon
cushon previously approved these changes Sep 22, 2023
@tjgq
Copy link

tjgq commented Sep 22, 2023

@cushon @hvadehra WDYT about this approach?

Comment on lines 86 to 88
# Provide the 'java` binary explicitly so that the correct path is used by
# Bazel even when the host platform differs from the execution platform.
java = glob(["bin/java.exe", "bin/java"])[0],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also:

  1. Document that java_runtime.java should (must?) be explicitly set, otherwise the default will be a guess based on the host platform?
  2. Update the TODO in JavaRuntime.java accordingly?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Whoops, I just noticed that this is not the main Bazel repo, but the comments still apply outside of this PR)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Document that java_runtime.java should (must?) be explicitly set, otherwise the default will be a guess based on the host platform?
  2. Update the TODO in JavaRuntime.java accordingly?

Documenting it as recommended sounds good to me.

I wonder if there's a path to making it mandatory and removing the logic for inferring it, but I'm not sure what the cleanup for that would look like.

@cushon
Copy link
Collaborator

cushon commented Sep 22, 2023

@cushon @hvadehra WDYT about this approach?

LGTM

toolchains/jdk_build_file.bzl Outdated Show resolved Hide resolved
cushon
cushon previously approved these changes Sep 22, 2023
@UebelAndre
Copy link

@cushon @comius @tjgq Friendly ping, Is this ready to merge?

@cushon cushon requested a review from hvadehra October 5, 2023 15:43
If the `java` attribute on `java_runtime` isn't set, Bazel guesses it
based on the host platform, which can be different from the execution
platform.

https://github.com/bazelbuild/bazel/blob/04a05677e4714434ec196c45a4ccbd8e0ef2f0ff/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java#L46

Work towards bazelbuild/bazel#19587
toolchains/jdk_build_file.bzl Show resolved Hide resolved
@copybara-service copybara-service bot merged commit b6a263d into bazelbuild:master Oct 6, 2023
@fmeum fmeum deleted the java-bin-path branch October 6, 2023 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants