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

Expose vanilla java toolchain #5984

Closed

Conversation

davido
Copy link
Contributor

@davido davido commented Aug 25, 2018

To use the latest supported language level from the --host_javabase, use
VanillaJavaBuilder (which should work with most host JDKs) and leave the
source/target/bootclasspath unset so they default to the latest
supported versions.

With this in place, new java_runtime can be used, e.g.:

java_runtime(
name = "jdk11",
java_home = "/usr/lib64/jvm/java-11",
visibility = ["//visibility:public"],
)

Now the JDK11 can be used with the language level 11:

$ bazel build --host_javabase=:jdk11
--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla
--java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla
:a

Related: #5723

To use the latest supported language level from the --host_javabase, use
VanillaJavaBuilder (which should work with most host JDKs) and leave the
source/target/bootclasspath unset so they default to the latest
supported versions.

With this in place, new java_runtime can be used, e.g.:

  java_runtime(
      name = "jdk11",
      java_home = "/usr/lib64/jvm/java-11",
      visibility = ["//visibility:public"],
  )

Now the JDK11 can be used with the language level 11:

  $ bazel build --host_javabase=:jdk11 \
    --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
    --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
    :a

Related: bazelbuild#5723
Copy link
Contributor

@lberki lberki left a comment

Choose a reason for hiding this comment

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

I think this looks entirely reasonable, but I'll leave the final judgement to @cushon .

@cushon
Copy link
Contributor

cushon commented Sep 5, 2018

Seems reasonable to me too, but VanillaJavaBuilder isn't currently supported, and this won't have any test coverage. It might be better to wait until some of the ongoing discussions about the Java tools are resolved before committing to providing this target.

@davido
Copy link
Contributor Author

davido commented Sep 14, 2018

@cushon @lberki As discussed in this issue, toolchain_vanilla would also allow to build stable branches and tags of project, that cannot be built with JDK9 javac, included in Bazel starting from 0.16.0. See these user complaints for the whole story: [1].

@cushon
Copy link
Contributor

cushon commented Sep 14, 2018

Can you share your requirements with the "incompatible changes policy" thread on bazel-discuss@?

I'm not opposed to creating a target for VanillaJavaBuilder, it currently it's unsupported and not something I really recommend taking a dependency on. It's also not a complete solution to let you build old versions of your code with new versions of Bazel, since from the discussion in the thread there's only going to be ~1 release of compatibility for breaking changes.

@davido
Copy link
Contributor Author

davido commented Sep 20, 2018

@cushon Any suggestion how to proceed here? Now, that Guice 4.2.1 was released with proper JDK 10 support, the only missing link in the chain to support Gerrit build with JDK 10 (and next week with JDK 11), is the missing easy and supported way to use Vanilla Java Builder exposed by vanilla_toolchain in Bazel.

I understand, your POV, to not committed to maintain that halb backed support for new toolchain. Still I would like to avoid adding it to gerrit as well. Any further ideas?

What about adding it to another place? Like to bazel_skylib? We use it already:

http_archive(
    name = "bazel_skylib",
    sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
    strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
    urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)

load("@bazel_skylib//:lib.bzl", "versions")

versions.check(minimum_bazel_version = "0.17.1")

@cushon
Copy link
Contributor

cushon commented Sep 20, 2018

Sorry for the delay. I think it's fine to add this for now, I don't have any better ideas until using JDK 10 and 11 with Bazel is fully supported.

@bazel-io bazel-io closed this in 0bef68e Sep 20, 2018
@davido davido deleted the expose_vanilla_java_toochain branch September 20, 2018 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants