diff --git a/.aspect/bazelrc/java.bazelrc b/.aspect/bazelrc/java.bazelrc new file mode 100644 index 000000000..9a3532aa3 --- /dev/null +++ b/.aspect/bazelrc/java.bazelrc @@ -0,0 +1,27 @@ +# Aspect recommended Bazel flags when using rules_java and rules_jvm_external + +# Pin java versions to desired language level +# See https://bazel.build/docs/bazel-and-java#java-versions +# and https://en.wikipedia.org/wiki/Java_version_history + +# What version of Java are the source files in this repo? +# See https://bazel.build/docs/user-manual#java-language-version +common --java_language_version=17 + +# The Java language version used to build tools that are executed during a build +# See https://bazel.build/docs/user-manual#tool-java-language-version +common --tool_java_language_version=17 + +# The version of JVM to use to execute the code and run the tests. +# NB: The default value is local_jdk which is non-hermetic. +# See https://bazel.build/docs/user-manual#java-runtime-version +common --java_runtime_version=remotejdk_17 + +# The version of JVM used to execute tools that are needed during a build. +# See https://bazel.build/docs/user-manual#tool-java-runtime-version +common --tool_java_runtime_version=remotejdk_17 + +# Repository rules, such as rules_jvm_external: put Bazel's JDK on the path. +# Avoids non-hermeticity from dependency on a JAVA_HOME pointing at a system JDK +# see https://github.com/bazelbuild/rules_jvm_external/issues/445 +common --repo_env=JAVA_HOME=../bazel_tools/jdk diff --git a/docs/bazelrc_presets.md b/docs/bazelrc_presets.md index 1031cf009..64cc5348d 100644 --- a/docs/bazelrc_presets.md +++ b/docs/bazelrc_presets.md @@ -27,7 +27,7 @@ the `presets` attribute. | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name | a unique name for this target | none | -| presets | a list of preset names to keep up-to-date | `["bazel6", "bazel7", "ci", "convenience", "correctness", "debug", "javascript", "performance"]` | +| presets | a list of preset names to keep up-to-date | `["bazel6", "bazel7", "ci", "convenience", "correctness", "debug", "java", "javascript", "performance"]` | | kwargs | Additional arguments to pass to `write_source_files` | none | diff --git a/lib/bazelrc_presets.bzl b/lib/bazelrc_presets.bzl index a34e6bf02..35940ec6b 100644 --- a/lib/bazelrc_presets.bzl +++ b/lib/bazelrc_presets.bzl @@ -12,6 +12,7 @@ ALL_PRESETS = [ "convenience", "correctness", "debug", + "java", "javascript", "performance", ]