Add support for toolchain java 15

Closes https://github.com/bazelbuild/bazel/issues/11871

I modelled this on @davido's addition of a java 14 toolchain, here:[https://github.com/bazelbuild/bazel/pull/11514](url).

The test plan has the same form:

Create java_tools from this commit:
`  $ bazel build src:java_tools_java11.zip`

Switch to using the java_tools from the above step in WORKSPACE file:

```
  load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
  http_archive(
    name = "remote_java_tools_linux",
    urls = [
        "file:///<path to the java_tools_java11.zip>",
    ],
  )

```
Add Zulu OpenJDK15 to use as javabase in WORKSPACE file:
```
  http_archive(
    name = "openjdk15_linux_archive",
    build_file_content = """
java_runtime(name = 'runtime', srcs =  glob(['**']), visibility = ['//visibility:public'])
exports_files(["WORKSPACE"], visibility = ["//visibility:public"])
""",
    strip_prefix = "zulu15.27.17-ca-jdk15.0.0-linux_x64",
    urls = ["https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz"],
  )
```

Activate custom java toolchain and javabase in .bazelrc file:
```
  build --java_toolchain=@remote_java_tools_linux//:toolchain_jdk_15
  build --host_java_toolchain=@remote_java_tools_linux//:toolchain_jdk_15
  build --javabase=@openjdk15_linux_archive//:runtime
  build --host_javabase=@openjdk15_linux_archive//:runtime

```
Create Java 15 example class file:
```
public class Javac15Example {
  static String textBlock = """
              Hello,
              World
              """;
  public static void main(String[] args) {
    System.out.println(textBlock);
  }
}

```
Add Bazel file to build Java 15 syntax class:
```
  java_binary(
    name = "Javac15Example",
    srcs = ["Javac15Example.java"],
    main_class = "Javac15Example",
  )

```
Test that it works as expected:
```
  $ bazel run java:Javac15Example
INFO: Analyzed target //java:Javac15Example (1 packages loaded, 2 targets configured).
INFO: Found 1 target...
INFO: From Building java/Javac15Example.jar (1 source file):
Target //java:Javac15Example up-to-date:
  bazel-bin/java/Javac15Example.jar
  bazel-bin/java/Javac15Example
INFO: Elapsed time: 1.502s, Critical Path: 1.30s
INFO: 1 process: 1 worker.
INFO: Build completed successfully, 2 total actions
INFO: Build completed successfully, 2 total actions
Hello,
World
```

Closes #12168.

PiperOrigin-RevId: 335931179
8 files changed
tree: 783a2ffb858f4f9ba15800383ff26c6a674144cd
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .bazelrc
  9. .gitattributes
  10. .gitignore
  11. AUTHORS
  12. BUILD
  13. CHANGELOG.md
  14. CODEBASE.md
  15. CODEOWNERS
  16. combine_distfiles.py
  17. combine_distfiles_to_tar.sh
  18. compile.sh
  19. CONTRIBUTING.md
  20. CONTRIBUTORS
  21. distdir.bzl
  22. ISSUE_TEMPLATE.md
  23. LICENSE
  24. README.md
  25. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status