Make default java_toolchain compile protos as java 7. Fixes https://github.com/bazelbuild/bazel/issues/2829 Without this change, there is no way to use Bazel to build a release Android build (--noincremental_dexing) with java 8 and protos. RELNOTES: Java protos are compiled to Java 7 bytecode. PiperOrigin-RevId: 165500316
diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD index 8ed90ef..9029782 100644 --- a/tools/jdk/BUILD +++ b/tools/jdk/BUILD
@@ -155,6 +155,16 @@ java_toolchain( name = "toolchain", bootclasspath = [":bootclasspath"], + compatible_javacopts = { + # Restrict protos to Java 7 so that they are compatible with Android. + "proto": [ + "-source", + "7", + "-target", + "7", + "-XDallowBetterNullChecks=false", + ], + }, encoding = "UTF-8", extclasspath = [":extclasspath"], forcibly_disable_header_compilation = 0,