From 547a623455e0bfdf28635f72327d01dfcb69ca71 Mon Sep 17 00:00:00 2001 From: Chris Heisterkamp Date: Tue, 31 Oct 2023 15:34:29 -0700 Subject: [PATCH] Add javac_option to pass release flag to javac --- kotlin/internal/jvm/compile.bzl | 2 +- src/main/starlark/core/options/opts.javac.bzl | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/kotlin/internal/jvm/compile.bzl b/kotlin/internal/jvm/compile.bzl index e2e9b54a5..5b1df20fb 100644 --- a/kotlin/internal/jvm/compile.bzl +++ b/kotlin/internal/jvm/compile.bzl @@ -763,7 +763,7 @@ def _run_kt_java_builder_actions( # If there is Java source or KAPT generated Java source compile that Java and fold it into # the final ABI jar. Otherwise just use the KT ABI jar as final ABI jar. if srcs.java or generated_kapt_src_jars or srcs.src_jars: - javac_opts = javac_options_to_flags(toolchains.kt.javac_options) + javac_opts = javac_options_to_flags(ctx.attr.javac_opts[JavacOptions] if ctx.attr.javac_opts else toolchains.kt.javac_options) # Kotlin takes care of annotation processing. Note that JavaBuilder "discovers" # annotation processors in `deps` also. diff --git a/src/main/starlark/core/options/opts.javac.bzl b/src/main/starlark/core/options/opts.javac.bzl index bfad8c8a5..782ddad46 100644 --- a/src/main/starlark/core/options/opts.javac.bzl +++ b/src/main/starlark/core/options/opts.javac.bzl @@ -29,6 +29,21 @@ _JOPTS = { "report": None, }, ), + "release": struct( + args = dict( + default = "default", + doc = "Compile for the specified Java SE release", + values = ["default", "8", "11", "17", "21"], + ), + type = attr.string, + value_to_flag = { + "8": ["--release 8"], + "11": ["--release 11"], + "17": ["--release 17"], + "21": ["--release 21"], + "default": None, + }, + ), "x_ep_disable_all_checks": struct( args = dict( default = False,