diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2016-04-20 13:58:08 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-04-20 14:23:56 +0000 |
commit | 0ad9f5e33c845cd5e26ac34b80d3892cce84f710 (patch) | |
tree | b48739f7e14dda53fa91a1ada79855730f7855f5 /third_party/java | |
parent | 01e7914245132a07ceb222eb21d1a015b701782d (diff) |
Refactor JDK 7 build to use the vendored version of it
Along the path, fix the build for JDK 7 and get rid of
most ugliness in the JDK 7 build. Now simply setting
JAVA_VERSION to 1.7 will build a JDK 7 compatible version.
Fixes #1159.
--
Change-Id: I9599283844a57d9e053f12d37445907f22a9232e
Reviewed-on: https://bazel-review.googlesource.com/#/c/3452
MOS_MIGRATED_REVID=120332747
Diffstat (limited to 'third_party/java')
-rw-r--r-- | third_party/java/jdk/README.md | 23 | ||||
-rw-r--r-- | third_party/java/jdk/javabuilder/BUILD | 13 | ||||
-rw-r--r-- | third_party/java/jdk/langtools/BUILD | 26 |
3 files changed, 60 insertions, 2 deletions
diff --git a/third_party/java/jdk/README.md b/third_party/java/jdk/README.md new file mode 100644 index 0000000000..02c794ae20 --- /dev/null +++ b/third_party/java/jdk/README.md @@ -0,0 +1,23 @@ +# Java compilers in Bazel + +Bazel compiles Java code using a custom builder. This builder is called +JavaBuilder and its code lies in //src/java_tools/buildjar. To build Java +code, JavaBuilder use the Java compiler from the JDK. To support +[ErrorProne](http://errorprone.info) checks, we vendor a custom build +of the Java compiler code. This is the raw version of the Java compiler +from [OpenJDK](https://openjdk.java.net) but compiled for a lower +version of the JRE. Those builds are vendored in +//third_party/java/jdk/langtools. + +Current Bazel supports running on a JRE 8 only because the default Java +compiler used (//third_party/java/jdk/langtools/javac.jar) is the +Java compiler of OpenJDK 9 compiled to run on a JRE 8. This cannot +be built to run on a JRE 7 because of code incompatiblity. Bazel's +JavaBuilder at HEAD cannot be linked with earlier version of the +Java compiler (it depends on some internals of the Java compiler). + +To build a version of Bazel that can run on a JRE 7, we need to rely +on the version of JavaBuilder provided with Bazel 0.1.0 +(//third_party/java/jdk/javabuilder/JavaBuilder_0.1.0_deploy.jar) which works +with a Java compiler of OpenJDK 8 compiled to run on a JRE 7 +(//third_party/java/jdk/langtools/javac7.jar). diff --git a/third_party/java/jdk/javabuilder/BUILD b/third_party/java/jdk/javabuilder/BUILD new file mode 100644 index 0000000000..f670c45bcd --- /dev/null +++ b/third_party/java/jdk/javabuilder/BUILD @@ -0,0 +1,13 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 license + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) + +filegroup( + name = "JavaBuilder_0.1.0", + srcs = ["JavaBuilder_0.1.0_deploy.jar"], +) diff --git a/third_party/java/jdk/langtools/BUILD b/third_party/java/jdk/langtools/BUILD index a542ae28cb..e87fa27c1d 100644 --- a/third_party/java/jdk/langtools/BUILD +++ b/third_party/java/jdk/langtools/BUILD @@ -4,7 +4,16 @@ licenses(["restricted"]) # GNU GPL v2 with Classpath exception filegroup( name = "srcs", - srcs = glob(["**"]), + srcs = select({ + "//tools/jdk:jdk7": [ + "BUILD", + "javac7.jar", + ], + "//conditions:default": [ + "BUILD", + "javac.jar", + ], + }), ) java_import( @@ -14,5 +23,18 @@ java_import( filegroup( name = "javac_jar", - srcs = ["javac.jar"], + srcs = select({ + "//tools/jdk:jdk7": ["javac7.jar"], + "//conditions:default": ["javac.jar"], + }), +) + +java_import( + name = "javac7", + jars = ["javac7.jar"], +) + +filegroup( + name = "javac7_jar", + srcs = ["javac7.jar"], ) |