Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "abseil-cpp", version = "20260107.1", repo_name = "absl")
bazel_dep(name = "nlohmann_json", version = "3.12.0.bcr.1", repo_name = "json")
bazel_dep(name = "fmt", version = "12.1.0-codeql.1")
bazel_dep(name = "rules_kotlin", version = "2.2.2-codeql.1")
bazel_dep(name = "rules_kotlin", version = "2.4.21-codeql.1")
bazel_dep(name = "gazelle", version = "0.54.0")
bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1")
bazel_dep(name = "googletest", version = "1.18.0.bcr.1")
Expand All @@ -37,6 +37,14 @@ bazel_dep(name = "zstd", version = "1.5.7.bcr.1")

bazel_dep(name = "buildifier_prebuilt", version = "10.1.0", dev_dependency = True)

# Pin the compiler to support the Kotlin 1.8 and 1.9 language versions required by older extractors.
kotlin = use_extension("@rules_kotlin//src/main/starlark/core/repositories:bzlmod_setup.bzl", "rules_kotlin_extensions")
kotlin.kotlinc_version(
sha256 = "a623871f1cd9c938946948b70ef9170879f0758043885bbd30c32f024e511714",
version = "2.2.21",
)
use_repo(kotlin, "btapi_impl", "com_github_google_ksp", "com_github_jetbrains_kotlin", "com_github_jetbrains_kotlin_git", "com_github_pinterest_ktlint", "jarjar", "kotlin_build_tools_api", "kotlinx_coroutines_core_jvm", "kotlinx_serialization_core_jvm", "kotlinx_serialization_json", "kotlinx_serialization_json_jvm")

# Keep edition and version approximately in sync with internal repo.
# the versions there are canonical, the versions here are used for CI in github/codeql, as well as for the vendoring of dependencies.
RUST_EDITION = "2024"
Expand Down
1 change: 1 addition & 0 deletions java/kotlin-extractor/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def _kotlin_dep_impl(repository_ctx):
"kotlin-stdlib.jar",
"kotlin-reflect.jar",
"kotlin-script-runtime.jar",
"kotlinx-coroutines-core-jvm.jar",
"trove4j.jar",
):
repository_ctx.symlink("empty.zip", jar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6966,7 +6966,7 @@ open class KotlinFileExtractor(
tw.writeExprs_stringliteral(id, type.javaResult.id, parent, idx)
tw.writeExprsKotlinType(id, type.kotlinResult.id)
extractExprContext(id, locId, enclosingCallable, enclosingStmt)
tw.writeNamestrings(toQuotedLiteral(v.toString()), v.toString(), id)
tw.writeNamestrings(toQuotedLiteral(v), v, id)
}
}
v == null -> {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
"""Bazel module manifest for the released rules_kotlin package."""

module(
name = "rules_kotlin",
version = "2.2.2-codeql.1",
version = "2.4.21-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 = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "rules_java", version = "8.9.0")
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")
bazel_dep(name = "bazel_worker_api", version = "0.0.8")
bazel_dep(name = "bazel_worker_java", version = "0.0.8")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_android", version = "0.7.3")
bazel_dep(name = "bazel_features", version = "1.39.0")
bazel_dep(name = "bazel_lib", version = "3.1.0")

rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
use_repo(rules_java_toolchains, "remote_java_tools")
Expand All @@ -26,13 +24,16 @@ rules_kotlin_extensions = use_extension(
)
use_repo(
rules_kotlin_extensions,
"btapi_impl",
"com_github_google_ksp",
"com_github_jetbrains_kotlin",
"com_github_pinterest_ktlint",
"kotlin_build_tools_impl",
"jarjar",
"kotlin_build_tools_api",
"kotlinx_coroutines_core_jvm",
"kotlinx_serialization_core_jvm",
"kotlinx_serialization_json",
"kotlinx_serialization_json_jvm",
)

register_toolchains("//kotlin/internal:default_toolchain")
register_toolchains("//kotlin:default_toolchain")
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CodeQL still builds extractors with Kotlin 1.8 and 1.9 language/API versions.
Keep those supported and keep the API version aligned with the language version.
--- a/src/main/starlark/core/options/opts.kotlinc.bzl
+++ b/src/main/starlark/core/options/opts.kotlinc.bzl
@@ -93,9 +93,7 @@
def _map_language_version_to_flag(version):
if not version:
return None
- if int(version.split(".")[0]) < 2:
- fail("rules_kotlin requires language_version 2.0 or newer; got %s" % version)
- return ["-language-version=%s" % version]
+ return ["-language-version=%s" % version, "-api-version=%s" % version]

def _map_xxlanguage_to_flag(values):
return ["-XXLanguage:%s" % v for v in values]
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ allows us to not have to specify that option (and therefore pull in `rules_kotli
internal repo.
--- a/kotlin/settings/BUILD.bazel
+++ b/kotlin/settings/BUILD.bazel
@@ -16,6 +16,6 @@ release_archive(
@@ -16,7 +16,7 @@
# Flag that controls the emission of jdeps files during kotlin jvm compilation.
bool_flag(
name = "jvm_emit_jdeps",
- build_setting_default = True, # Upstream default behavior
+ build_setting_default = False,
visibility = ["//visibility:public"],
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
rules_kotlin 2.4 propagates the Kotlin warning mode to javac, so the extractor's
Kotlin warn = "error" setting also makes Java warnings fatal. This breaks the
Java 8 target with JDK 25's obsolete source/target option warnings. Keep Kotlin
warnings-as-errors for Kotlin compilation without changing javac warning behavior.
--- a/kotlin/internal/jvm/compile.bzl
+++ b/kotlin/internal/jvm/compile.bzl
@@ -1162,21 +1162,6 @@
for flag in javac_options_to_flags(plugin[JavacOptions])
])

- # Compile the Java half with the same warning mode as the kotlin part, unless the javac
- # options (or a plugin's) already set one: a single `warn` value governs the whole target.
- # A per-diagnostic level in `x_warning_level` limits the derivation, because javac has no
- # equivalent of `-Xwarning-level`. A diagnostic kept at `warning` or `disabled` under
- # `warn = "error"` must not turn every javac warning into an error, and a diagnostic raised
- # to `warning` or `error` under `warn = "off"` must not silence every javac warning.
- if "-nowarn" not in javac_opts and "-Werror" not in javac_opts:
- kotlinc_warn = getattr(kotlinc_options, "warn", None) if kotlinc_options else None
- warning_levels = (getattr(kotlinc_options, "x_warning_level", None) if kotlinc_options else None) or {}
- levels = warning_levels.values()
- if kotlinc_warn == "off" and "error" not in levels and "warning" not in levels:
- javac_opts.append("-nowarn")
- elif kotlinc_warn == "error" and "warning" not in levels and "disabled" not in levels:
- javac_opts.append("-Werror")
-
java_info = java_common.compile(
ctx,
source_files = srcs.java,
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"integrity": "sha256-qjJVRS2+m1LaK6d4fwhl8QeAWIUQnznD1br8IaUhvLY=",
"url": "https://github.com/bazel-contrib/rules_kotlin/releases/download/v2.4.21/rules_kotlin-v2.4.21.tar.gz",
"patches": {
"codeql_add_language_version_option.patch": "sha256-ml0fzhPwNozMi6yKtEn9YLM8LSQE4BWiimdwYzennCo=",
"codeql_do_not_emit_jdeps.patch": "sha256-yoBFnSWJyeF+gyhX+03TMTnRxUQJjup/f/KORdxVsAE=",
"codeql_do_not_propagate_kotlin_warning_mode_to_javac.patch": "sha256-TvfKfINvi1/tcLq3HDUs2doD4kr8AkMv0nsZvUHPjwg="
},
"patch_strip": 1
}
2 changes: 1 addition & 1 deletion misc/bazel/registry/modules/rules_kotlin/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"github:bazelbuild/rules_kotlin"
],
"versions": [
"2.2.2-codeql.1"
"2.4.21-codeql.1"
],
"yanked_versions": {}
}
Loading