Kotlin: Update kotlin_rules to 2.2.0 and remove support for Kotlin 1.6 and 1.7

This commit is contained in:
Anders Fugmann
2025-12-04 15:56:48 +01:00
parent f4edff9452
commit beff080ee7
20 changed files with 33 additions and 87 deletions

View File

@@ -24,7 +24,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl")
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
bazel_dep(name = "fmt", version = "12.1.0-codeql.1")
bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1")
bazel_dep(name = "rules_kotlin", version = "2.2.0-codeql.1")
bazel_dep(name = "gazelle", version = "0.40.0")
bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
@@ -221,10 +221,6 @@ use_repo(
kotlin_extractor_deps,
"codeql_kotlin_defaults",
"codeql_kotlin_embeddable",
"kotlin-compiler-1.6.0",
"kotlin-compiler-1.6.20",
"kotlin-compiler-1.7.0",
"kotlin-compiler-1.7.20",
"kotlin-compiler-1.8.0",
"kotlin-compiler-1.9.0-Beta",
"kotlin-compiler-1.9.20-Beta",
@@ -234,10 +230,6 @@ use_repo(
"kotlin-compiler-2.1.20-Beta1",
"kotlin-compiler-2.2.0-Beta1",
"kotlin-compiler-2.2.20-Beta2",
"kotlin-compiler-embeddable-1.6.0",
"kotlin-compiler-embeddable-1.6.20",
"kotlin-compiler-embeddable-1.7.0",
"kotlin-compiler-embeddable-1.7.20",
"kotlin-compiler-embeddable-1.8.0",
"kotlin-compiler-embeddable-1.9.0-Beta",
"kotlin-compiler-embeddable-1.9.20-Beta",
@@ -247,10 +239,6 @@ use_repo(
"kotlin-compiler-embeddable-2.1.20-Beta1",
"kotlin-compiler-embeddable-2.2.0-Beta1",
"kotlin-compiler-embeddable-2.2.20-Beta2",
"kotlin-stdlib-1.6.0",
"kotlin-stdlib-1.6.20",
"kotlin-stdlib-1.7.0",
"kotlin-stdlib-1.7.20",
"kotlin-stdlib-1.8.0",
"kotlin-stdlib-1.9.0-Beta",
"kotlin-stdlib-1.9.20-Beta",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,9 +1,5 @@
# when updating this list, `bazel mod tidy` should be run from `codeql` to update `MODULE.bazel`
VERSIONS = [
"1.6.0",
"1.6.20",
"1.7.0",
"1.7.20",
"1.8.0",
"1.9.0-Beta",
"1.9.20-Beta",

View File

@@ -1,9 +0,0 @@
{
"integrity": "sha256-4USKVrJGJAeyaI3qht9cN1s2oJkb1HjC3dlMlxaBJeI=",
"url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.1.3/rules_kotlin-v2.1.3.tar.gz",
"patches": {
"codeql_do_not_emit_jdeps.patch": "sha256-1ir4Aio1SICxnj1wafQ0GefT/m7bwn2n+SQwq19V3A8=",
"codeql_add_language_version_option.patch": "sha256-F7RthnrO6kJlCNcQ76L1Utqll2OwyeFZ/HmT82NwgB4="
},
"patch_strip": 1
}

View File

@@ -1,16 +1,23 @@
module(
name = "rules_kotlin",
version = "2.1.3-codeql.1",
version = "2.2.0-codeql.1",
compatibility_level = 1,
repo_name = "rules_kotlin",
)
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
# bazel_dep(name = "rules_java", version = "7.2.0")
bazel_dep(name = "rules_java", version = "7.2.0")
bazel_dep(name = "rules_python", version = "0.23.1")
bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "rules_android", version = "0.1.1")
bazel_dep(name = "rules_android", version = "0.6.4")
bazel_dep(name = "bazel_features", version = "1.25.0")
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_proto", version = "6.0.2", repo_name = "rules_proto")
bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "py_absl")
bazel_dep(name = "rules_cc", version = "0.0.16")
rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
use_repo(rules_java_toolchains, "remote_java_tools")
rules_kotlin_extensions = use_extension(
"//src/main/starlark/core/repositories:bzlmod_setup.bzl",
@@ -24,12 +31,7 @@ use_repo(
"kotlinx_serialization_core_jvm",
"kotlinx_serialization_json",
"kotlinx_serialization_json_jvm",
"kotlin_build_tools_impl",
)
register_toolchains("//kotlin/internal:default_toolchain")
# TODO(bencodes) We should be able to remove this once rules_android has rolled out official Bzlmod support
remote_android_extensions = use_extension("@bazel_tools//tools/android:android_extensions.bzl", "remote_android_tools_extensions")
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

View File

@@ -1,22 +1,20 @@
diff --git a/src/main/starlark/core/options/opts.kotlinc.bzl b/src/main/starlark/core/options/opts.kotlinc.bzl
index 76df826..ef2d6ca 100644
--- a/src/main/starlark/core/options/opts.kotlinc.bzl
+++ b/src/main/starlark/core/options/opts.kotlinc.bzl
@@ -33,6 +33,11 @@ def _map_jdk_release_to_flag(version):
--- a/src/main/starlark/core/options/opts.kotlinc.bzl 2000-01-01 01:00:00.000000000 +0100
+++ b/src/main/starlark/core/options/opts.kotlinc.bzl 2025-11-17 16:51:01.012063056 +0100
@@ -51,6 +51,11 @@
return None
return ["-Xjdk-release=%s" % version]
+def _map_language_version_to_flag(version):
+ if not version:
+ return None
+ return ["-language-version=%s" % version, "-api-version=%s" % version]
+
_KOPTS_ALL = {
"warn": struct(
"include_stdlibs": struct(
args = dict(
@@ -429,6 +434,15 @@ _KOPTS_ALL = {
@@ -495,6 +500,15 @@
value_to_flag = None,
map_value_to_flag = _map_jdk_release_to_flag,
map_value_to_flag = _map_warning_level,
),
+ "language_version": struct(
+ args = dict(
@@ -28,5 +26,5 @@ index 76df826..ef2d6ca 100644
+ map_value_to_flag = _map_language_version_to_flag,
+ ),
}
def _merge(key, rule_defined):

View File

@@ -1,11 +1,9 @@
Emitting jdeps is broken for the 2.0.0 kotlin extractor, and we don't need those files.
Patching it here rather than passing `--@rules_kotlin//kotlin/settings:jvm_emit_jdeps=false`
allows us to not have to specify that option (and therefore pull in `rules_kotlin`) in `semmle-code`.
diff --git a/kotlin/settings/BUILD.bazel b/kotlin/settings/BUILD.bazel
index 2c93c11..f352b80 100644
--- a/kotlin/settings/BUILD.bazel
+++ b/kotlin/settings/BUILD.bazel
@@ -25,7 +25,7 @@ release_archive(
@@ -16,6 +16,6 @@ release_archive(
# Flag that controls the emission of jdeps files during kotlin jvm compilation.
bool_flag(
name = "jvm_emit_jdeps",
@@ -13,4 +11,4 @@ index 2c93c11..f352b80 100644
+ build_setting_default = False,
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,9 @@
{
"integrity": "sha256-4STROYYIW8ChW+LIXBQVurVwhEK3jSSf4iv430OlNA0=",
"url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.2.0/rules_kotlin-v2.2.0.tar.gz",
"patches": {
"codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU=",
"codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM="
},
"patch_strip": 1
}

View File

@@ -21,7 +21,7 @@
"github:bazelbuild/rules_kotlin"
],
"versions": [
"2.1.3-codeql.1"
"2.2.0-codeql.1",
],
"yanked_versions": {}
}