Skip to content

Conversation

menny
Copy link
Contributor

@menny menny commented Mar 14, 2023

This is a continuation of 27fe30b
This is useful for setting constraints on java toolchains.

@ShreeM01 ShreeM01 added team-Rules-Java Issues for Java rules awaiting-review PR is awaiting review from an assigned reviewer labels Mar 14, 2023
@katre
Copy link
Contributor

katre commented Mar 14, 2023

Please update the description to say what can now use target and exec constraints, I was very confused until I read the code.

@menny menny changed the title Allow specifying target and exec constrains Allow specifying target and exec constrains in remote_java_repository Mar 14, 2023
@menny
Copy link
Contributor Author

menny commented Mar 14, 2023

I was looking at the commit that changed exec_compatible_with to target_compatible_with and I wonder if we need to change the usages back to exec_compatible_with in the jdk workspace template. WDYT?

@menny
Copy link
Contributor Author

menny commented Mar 14, 2023

The setup that failed for us is this:

  • we build on a Linux-x86_64 machine. Our JDK is setup using remote_java_repository.
  • we are building an Android app with C++ library.
  • for each android CPU type, we have a different platform.

Our JDKs are with these compatible_with:

  • Linux: ["@platforms//os:linux", "@platforms//cpu:x86_64"]
  • mac Intel: ["@platforms//os:macos", "@platforms//cpu:x86_64"]
  • mac Apple Silicon: ["@platforms//os:macos", "@platforms//cpu:aarch64"]
  • Windows: ["@platforms//os:windows", "@platforms//cpu:x86_64"]

Our command line to build the app with arm64 variant will look something like this:

bazelisk build //src/main/java/com/app:app --platforms=@client-core//other/bazel/platform:android-arm64

This will fail with bazel 6.2 since our JDKs are not target compatible with the specified platforms argument.

@menny
Copy link
Contributor Author

menny commented Mar 14, 2023

Switching from target_compatible_with to exec_compatible_with solves our problem. My rationale was that the Java compiler produces byte-code artifacts that are cross-platform, but the binaries in the JDK package are specified to the host (exec).

@hvadehra
Copy link
Member

The file changed here have been moved out of bazel and now resides in @rules_java. If this is still an issue with Bazel 7, please consider opening a PR in that repo.

@hvadehra hvadehra closed this Oct 23, 2023
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Rules-Java Issues for Java rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants