
The main feature of toolchain_vanilla definition is to support newer Java language versions that the embedded JDK, e.g.: at the time of this change, toolchain_java could be used to support building with JDK 13 and produce byte code major version 57, using the combination of absolute javabase and toolchain_vanilla: $ bazel build --define=ABSOLUTE_JAVABASE=/use/local/bin/jdk-13 \ --javabase=@bazel_tools//tools/jdk:absolute_javabase \ --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \ --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ :gerrit Unfortunately, [1] sets source and target language levels to Java 8 to restore backwards compatibility, to fix a regression, that was introduced during upgrade of remote JDK version to Java 11, in: [2]. This change restores the neutrality of toolchain_vanilla declaration by unsetting source and target language level versions. So that the bazel invocation in the example above produces byte code major version 57 (Java 13), and not 52 (Java 8) as it is the case before this change. Also add a TODO, to remove the workaround, when this issue is fixed: [3]. [1]6ef6d879ab
[2]bad5a2beb9
[3] https://github.com/bazelbuild/bazel/issues/9415 Bug: Issue 11571 Change-Id: I721067202de744883bc8c74bb4106ad08f19c66d
134 lines
5.0 KiB
Python
134 lines
5.0 KiB
Python
load(
|
|
"@bazel_tools//tools/jdk:default_java_toolchain.bzl",
|
|
"JDK9_JVM_OPTS",
|
|
"default_java_toolchain",
|
|
)
|
|
load("@rules_java//java:defs.bzl", "java_package_configuration")
|
|
load("@rules_python//python:defs.bzl", "py_binary")
|
|
|
|
exports_files(["nongoogle.bzl"])
|
|
|
|
py_binary(
|
|
name = "merge_jars",
|
|
srcs = ["merge_jars.py"],
|
|
main = "merge_jars.py",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# TODO(davido): Remove this workaround and switch to using toolchain_vanilla
|
|
# from this Bazel package again: @bazel_tools//tools/jdk:toolchain_vanilla,
|
|
# when this issue is fixed: https://github.com/bazelbuild/bazel/issues/9415.
|
|
default_java_toolchain(
|
|
name = "toolchain_vanilla",
|
|
forcibly_disable_header_compilation = True,
|
|
javabuilder = ["@bazel_tools//tools/jdk:vanillajavabuilder"],
|
|
jvm_opts = [],
|
|
source_version = "",
|
|
target_version = "",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
default_java_toolchain(
|
|
name = "error_prone_warnings_toolchain",
|
|
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
|
|
jvm_opts = JDK9_JVM_OPTS,
|
|
package_configuration = [
|
|
":error_prone",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Error Prone errors enabled by default; see ../.bazelrc for how this is
|
|
# enabled. This warnings list is originally based on:
|
|
# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl
|
|
# However, feel free to add any additional errors. Thus far they have all been pretty useful.
|
|
# TODO(davido): Enable ImmutableAnnotationChecker again when these issues are fixed:
|
|
# https://github.com/google/error-prone/issues/1348
|
|
# https://github.com/bazelbuild/bazel/issues/9378
|
|
java_package_configuration(
|
|
name = "error_prone",
|
|
javacopts = [
|
|
"-XepDisableWarningsInGeneratedCode",
|
|
"-Xep:AmbiguousMethodReference:ERROR",
|
|
"-Xep:AutoValueFinalMethods:ERROR",
|
|
"-Xep:BadAnnotationImplementation:ERROR",
|
|
"-Xep:BadComparable:ERROR",
|
|
"-Xep:BoxedPrimitiveConstructor:ERROR",
|
|
"-Xep:CannotMockFinalClass:ERROR",
|
|
"-Xep:ClassCanBeStatic:ERROR",
|
|
"-Xep:ClassNewInstance:ERROR",
|
|
"-Xep:DateFormatConstant:ERROR",
|
|
"-Xep:DefaultCharset:ERROR",
|
|
"-Xep:DoubleCheckedLocking:ERROR",
|
|
"-Xep:ElementsCountedInLoop:ERROR",
|
|
"-Xep:EqualsHashCode:ERROR",
|
|
"-Xep:EqualsIncompatibleType:ERROR",
|
|
"-Xep:ExpectedExceptionChecker:ERROR",
|
|
"-Xep:Finally:ERROR",
|
|
"-Xep:FloatingPointLiteralPrecision:ERROR",
|
|
"-Xep:FragmentInjection:ERROR",
|
|
"-Xep:FragmentNotInstantiable:ERROR",
|
|
"-Xep:FunctionalInterfaceClash:ERROR",
|
|
"-Xep:FutureReturnValueIgnored:ERROR",
|
|
"-Xep:GetClassOnEnum:ERROR",
|
|
"-Xep:ImmutableAnnotationChecker:OFF",
|
|
"-Xep:ImmutableEnumChecker:ERROR",
|
|
"-Xep:IncompatibleModifiers:ERROR",
|
|
"-Xep:InjectOnConstructorOfAbstractClass:ERROR",
|
|
"-Xep:InputStreamSlowMultibyteRead:ERROR",
|
|
"-Xep:IterableAndIterator:ERROR",
|
|
"-Xep:JUnit3FloatingPointComparisonWithoutDelta:ERROR",
|
|
"-Xep:JUnitAmbiguousTestClass:ERROR",
|
|
"-Xep:LiteralClassName:ERROR",
|
|
"-Xep:MissingCasesInEnumSwitch:ERROR",
|
|
"-Xep:MissingFail:ERROR",
|
|
"-Xep:MissingOverride:ERROR",
|
|
"-Xep:MutableConstantField:ERROR",
|
|
"-Xep:NarrowingCompoundAssignment:ERROR",
|
|
"-Xep:NonAtomicVolatileUpdate:ERROR",
|
|
"-Xep:NonOverridingEquals:ERROR",
|
|
"-Xep:NullableConstructor:ERROR",
|
|
"-Xep:NullablePrimitive:ERROR",
|
|
"-Xep:NullableVoid:ERROR",
|
|
"-Xep:OperatorPrecedence:ERROR",
|
|
"-Xep:OverridesGuiceInjectableMethod:ERROR",
|
|
"-Xep:PreconditionsInvalidPlaceholder:ERROR",
|
|
"-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR",
|
|
"-Xep:ProtocolBufferOrdinal:ERROR",
|
|
"-Xep:ReferenceEquality:ERROR",
|
|
"-Xep:RequiredModifiers:ERROR",
|
|
"-Xep:ShortCircuitBoolean:ERROR",
|
|
"-Xep:SimpleDateFormatConstant:ERROR",
|
|
"-Xep:StaticGuardedByInstance:ERROR",
|
|
"-Xep:StringEquality:ERROR",
|
|
"-Xep:SynchronizeOnNonFinalField:ERROR",
|
|
"-Xep:TruthConstantAsserts:ERROR",
|
|
"-Xep:TypeParameterShadowing:ERROR",
|
|
"-Xep:TypeParameterUnusedInFormals:ERROR",
|
|
"-Xep:URLEqualsHashCode:ERROR",
|
|
"-Xep:UnsynchronizedOverridesSynchronized:ERROR",
|
|
"-Xep:WaitNotInLoop:ERROR",
|
|
"-Xep:WildcardImport:ERROR",
|
|
],
|
|
packages = ["error_prone_packages"],
|
|
)
|
|
|
|
package_group(
|
|
name = "error_prone_packages",
|
|
packages = [
|
|
"//java/...",
|
|
"//javatests/...",
|
|
"//plugins/codemirror-editor/...",
|
|
"//plugins/commit-message-length-validator/...",
|
|
"//plugins/delete-project/...",
|
|
"//plugins/download-commands/...",
|
|
"//plugins/gitiles/...",
|
|
"//plugins/hooks/...",
|
|
"//plugins/plugin-manager/...",
|
|
"//plugins/replication/...",
|
|
"//plugins/reviewnotes/...",
|
|
"//plugins/singleusergroup/...",
|
|
"//plugins/webhooks/...",
|
|
],
|
|
)
|