From 491a7c8b0ce0d5e0d203c38665fc442d16df98ab Mon Sep 17 00:00:00 2001 From: Rieman Date: Fri, 12 May 2023 15:29:05 -0700 Subject: [PATCH 1/7] Update rules_kotlin to 1.8-RC-1 and Kotlin to 1.8.21 (#192) * Update rules_kotlin to 1.8-RC-1 and Kotlin 1.8.21 * Create a macro to execute kt_jvm_library with maven kotlin stdlib included. --- README.md | 2 +- WORKSPACE | 1 - build/common_jvm_maven.bzl | 3 +- build/kt_jvm_proto/defs.bzl | 2 +- .../BUILD.com_github_jetbrains_kotlin | 83 ------------------- build/rules_kotlin/defs.bzl | 27 ++++++ build/rules_kotlin/deps.bzl | 49 +---------- build/rules_kotlin/repo.bzl | 31 ++----- build/rules_kotlin/toolchain/BUILD.bazel | 1 + build/versions.bzl | 6 +- imports/kotlin/kotlin/BUILD.bazel | 9 +- .../kotlin/reflect/{jvm => }/BUILD.bazel | 2 +- .../aws/postgres/tools/BUILD.bazel | 2 +- .../org/wfanet/measurement/aws/s3/BUILD.bazel | 2 +- .../org/wfanet/measurement/common/BUILD.bazel | 6 +- .../measurement/common/crypto/BUILD.bazel | 2 +- .../common/crypto/testing/BUILD.bazel | 2 +- .../common/crypto/tink/BUILD.bazel | 2 +- .../common/crypto/tink/testing/BUILD.bazel | 2 +- .../common/db/liquibase/BUILD.bazel | 2 +- .../common/db/liquibase/tools/BUILD.bazel | 2 +- .../common/db/postgres/BUILD.bazel | 2 +- .../common/db/postgres/tools/BUILD.bazel | 2 +- .../measurement/common/db/r2dbc/BUILD.bazel | 2 +- .../common/db/r2dbc/ReadWriteContext.kt | 3 +- .../common/db/r2dbc/postgres/BUILD.bazel | 2 +- .../db/r2dbc/postgres/testing/BUILD.bazel | 2 +- .../measurement/common/graphviz/BUILD.bazel | 2 +- .../measurement/common/grpc/BUILD.bazel | 2 +- .../common/grpc/testing/BUILD.bazel | 2 +- .../measurement/common/identity/BUILD.bazel | 2 +- .../common/identity/testing/BUILD.bazel | 2 +- .../measurement/common/openid/BUILD.bazel | 2 +- .../measurement/common/testing/BUILD.bazel | 7 +- .../measurement/common/throttler/BUILD.bazel | 3 +- .../common/throttler/testing/BUILD.bazel | 2 +- .../measurement/gcloud/common/BUILD.bazel | 2 +- .../wfanet/measurement/gcloud/gcs/BUILD.bazel | 2 +- .../measurement/gcloud/postgres/BUILD.bazel | 2 +- .../gcloud/postgres/tools/BUILD.bazel | 2 +- .../measurement/gcloud/spanner/BUILD.bazel | 2 +- .../gcloud/spanner/testing/BUILD.bazel | 2 +- .../gcloud/spanner/tools/BUILD.bazel | 2 +- .../wfanet/measurement/storage/BUILD.bazel | 2 +- .../storage/filesystem/BUILD.bazel | 3 +- .../measurement/storage/forwarded/BUILD.bazel | 2 +- .../measurement/storage/testing/BUILD.bazel | 2 +- .../org/wfanet/measurement/common/BUILD.bazel | 1 - 48 files changed, 83 insertions(+), 216 deletions(-) delete mode 100644 build/rules_kotlin/BUILD.com_github_jetbrains_kotlin create mode 100644 build/rules_kotlin/defs.bzl rename imports/kotlin/kotlin/reflect/{jvm => }/BUILD.bazel (85%) diff --git a/README.md b/README.md index 63253ce65..604bd33ac 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Purpose -Implementation of comnmon JVM dependencies for the wfa repositories. +Implementation of common JVM dependencies for the wfa repositories. ### Technologies diff --git a/WORKSPACE b/WORKSPACE index bffcbc92b..aa1fb5b7c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -14,7 +14,6 @@ load( "COMMON_JVM_MAVEN_OVERRIDE_TARGETS", "common_jvm_maven_artifacts", ) - load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( diff --git a/build/common_jvm_maven.bzl b/build/common_jvm_maven.bzl index 08fc9ffd4..38c64d784 100644 --- a/build/common_jvm_maven.bzl +++ b/build/common_jvm_maven.bzl @@ -18,7 +18,6 @@ Adds external repos necessary for common-jvm. load( "//build/rules_kotlin:repo.bzl", - "RULES_KOTLIN_OVERRIDE_TARGETS", "rules_kotlin_maven_artifacts_dict", ) load( @@ -122,7 +121,7 @@ def common_jvm_maven_artifacts_dict(): return maven_artifacts -COMMON_JVM_MAVEN_OVERRIDE_TARGETS = dict(RULES_KOTLIN_OVERRIDE_TARGETS.items() + GRPC_KOTLIN_OVERRIDE_TARGETS.items()) +COMMON_JVM_MAVEN_OVERRIDE_TARGETS = GRPC_KOTLIN_OVERRIDE_TARGETS COMMON_JVM_EXCLUDED_ARTIFACTS = [ # Until the log2shell has been more widely mitigated, prohibit log4j totally. diff --git a/build/kt_jvm_proto/defs.bzl b/build/kt_jvm_proto/defs.bzl index 9dd7d1f32..0240b1635 100644 --- a/build/kt_jvm_proto/defs.bzl +++ b/build/kt_jvm_proto/defs.bzl @@ -18,7 +18,7 @@ Provides kt_jvm_proto_library to generate Kotlin protos. load("//build:defs.bzl", "get_real_short_path") load("@rules_proto//proto:defs.bzl", "ProtoInfo") -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") KtProtoLibInfo = provider( "Information for a Kotlin JVM proto library.", diff --git a/build/rules_kotlin/BUILD.com_github_jetbrains_kotlin b/build/rules_kotlin/BUILD.com_github_jetbrains_kotlin deleted file mode 100644 index 00263d689..000000000 --- a/build/rules_kotlin/BUILD.com_github_jetbrains_kotlin +++ /dev/null @@ -1,83 +0,0 @@ -# Replacement BUILD file for kotlin_compiler_repository from rules_kotlin. - -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_import") -load("@io_bazel_rules_kotlin//kotlin:js.bzl", "kt_js_import") - -package(default_visibility = ["//visibility:public"]) - -KOTLIN_RELEASE_VERSION = "{{kotlin_release_version}}" - -JETBRAINS_ANNOTATIONS_VERSION = "{{jetbrains_annotations_version}}" - -KT_JVM_STDLIBS = [ - "kotlin-stdlib", - "kotlin-stdlib-jdk7", - "kotlin-stdlib-jdk8", - "kotlin-reflect", - "kotlin-test", - "kotlin-script-runtime", -] - -KT_JS_STDLIBS = [ - "kotlin-test-js", - "kotlin-stdlib-js", -] - -filegroup( - name = "home", - srcs = glob(["**"]), -) - -kt_jvm_import( - name = "annotations", - jar = "lib/annotations-{version}.jar".format( - version = JETBRAINS_ANNOTATIONS_VERSION, - ), - neverlink = 1, - tags = [ - "maven_coordinates=org.jetbrains:annotations:{version}".format( - version = JETBRAINS_ANNOTATIONS_VERSION, - ), - ], -) - -kt_jvm_import( - name = "jvm-abi-gen", - jar = "lib/jvm-abi-gen.jar", -) - -kt_jvm_import( - name = "kotlin-compiler", - jar = "lib/kotlin-compiler.jar", - neverlink = 1, -) - -[ - kt_jvm_import( - name = lib, - jar = "lib/{lib}.jar".format(lib = lib), - srcjar = "lib/{lib}-sources.jar".format(lib = lib), - tags = [ - "maven_coordinates=org.jetbrains.kotlin:{lib}:{version}".format( - lib = lib, - version = KOTLIN_RELEASE_VERSION, - ), - ], - ) - for lib in KT_JVM_STDLIBS -] - -[ - kt_js_import( - name = lib, - jars = ["lib/{lib}.jar".format(lib = lib)], - srcjar = "lib/{lib}-sources.jar".format(lib = lib), - tags = [ - "maven_coordinates=org.jetbrains.kotlin:{lib}:{version}".format( - lib = lib, - version = KOTLIN_RELEASE_VERSION, - ), - ], - ) - for lib in KT_JS_STDLIBS -] diff --git a/build/rules_kotlin/defs.bzl b/build/rules_kotlin/defs.bzl new file mode 100644 index 000000000..7fc575110 --- /dev/null +++ b/build/rules_kotlin/defs.bzl @@ -0,0 +1,27 @@ +# Copyright 2023 The Cross-Media Measurement Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Macros for kt_jvm_library to include Maven kotlin stdlib.""" + +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", old_kt_jvm_library = "kt_jvm_library") + +def kt_jvm_library(name, deps = [], **kwargs): + old_kt_jvm_library( + name = name, + deps = [ + "//imports/kotlin/kotlin:stdlib", + "//imports/kotlin/kotlin/reflect", + ] + deps, + **kwargs + ) diff --git a/build/rules_kotlin/deps.bzl b/build/rules_kotlin/deps.bzl index b14ac2e70..d7d12e34b 100644 --- a/build/rules_kotlin/deps.bzl +++ b/build/rules_kotlin/deps.bzl @@ -25,60 +25,15 @@ load("//build:versions.bzl", "KOTLIN_RELEASE_VERSION") # KOTLIN_RELEASE_VERSION. JETBRAINS_ANNOTATIONS_VERSION = "13.0" +# buildifier: disable=unnamed-macro def rules_kotlin_deps(): compiler_release = kotlinc_version( release = KOTLIN_RELEASE_VERSION, - sha256 = "632166fed89f3f430482f5aa07f2e20b923b72ef688c8f5a7df3aa1502c6d8ba", + sha256 = "6e43c5569ad067492d04d92c28cdf8095673699d81ce460bd7270443297e8fd7", ) kotlin_repositories( compiler_release = compiler_release, ) - - # Override the Kotlin compiler repo with one that has Maven coordinate tags. - # - # TODO(bazelbuild/rules_kotlin#752): Drop once compiler repo deps are - # tagged with Maven coordinates. - _kotlin_compiler_repo( - name = "com_github_jetbrains_kotlin", - urls = [ - url.format(version = compiler_release.version) - for url in compiler_release.url_templates - ], - sha256 = compiler_release.sha256, - ) - native.register_toolchains( "@wfa_common_jvm//build/rules_kotlin/toolchain:toolchain", ) - -def _kotlin_compiler_repo_impl(repository_ctx): - attr = repository_ctx.attr - repository_ctx.download_and_extract( - attr.urls, - sha256 = attr.sha256, - stripPrefix = "kotlinc", - ) - repository_ctx.file( - "WORKSPACE", - content = "workspace(name = {name})".format(name = attr.name), - ) - repository_ctx.template( - "BUILD.bazel", - attr._build_template, - substitutions = { - "{{kotlin_release_version}}": KOTLIN_RELEASE_VERSION, - "{{jetbrains_annotations_version}}": JETBRAINS_ANNOTATIONS_VERSION, - }, - executable = False, - ) - -_kotlin_compiler_repo = repository_rule( - implementation = _kotlin_compiler_repo_impl, - attrs = { - "urls": attr.string_list(mandatory = True), - "sha256": attr.string(), - "_build_template": attr.label( - default = ":BUILD.com_github_jetbrains_kotlin", - ), - }, -) diff --git a/build/rules_kotlin/repo.bzl b/build/rules_kotlin/repo.bzl index 7acbdf534..24dc60c0b 100644 --- a/build/rules_kotlin/repo.bzl +++ b/build/rules_kotlin/repo.bzl @@ -21,25 +21,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//build:versions.bzl", "KOTLIN_RELEASE_VERSION") -_JETBRAINS_KOTLIN_OVERRIDE_TARGETS = { - "org.jetbrains.kotlin:kotlin-stdlib": "@com_github_jetbrains_kotlin//:kotlin-stdlib", - "org.jetbrains.kotlin:kotlin-stdlib-common": "@com_github_jetbrains_kotlin//:kotlin-stdlib", - "org.jetbrains.kotlin:kotlin-stdlib-jdk7": "@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7", - "org.jetbrains.kotlin:kotlin-stdlib-jdk8": "@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8", - "org.jetbrains.kotlin:kotlin-reflect": "@com_github_jetbrains_kotlin//:kotlin-reflect", - "org.jetbrains.kotlin:kotlin-test": "@com_github_jetbrains_kotlin//:kotlin-test", -} - -_JETBRAINS_OVERRIDE_TARGETS = { - "org.jetbrains:annotations": "@com_github_jetbrains_kotlin//:annotations", -} # @unused - -# Override targets for rules_kotlin. -# -# Despite the fact that the Kotlin compiler release bundles JetBrains, -# annotations, we intentionally do not include it as an override target since -# as of the 1.6 compiler release it is quite an old version (13). -RULES_KOTLIN_OVERRIDE_TARGETS = _JETBRAINS_KOTLIN_OVERRIDE_TARGETS +_JETBRAINS_KOTLIN_LIBRARIES = [ + "org.jetbrains.kotlin:kotlin-stdlib", + "org.jetbrains.kotlin:kotlin-stdlib-common", + "org.jetbrains.kotlin:kotlin-reflect", + "org.jetbrains.kotlin:kotlin-test", +] def _rules_kotlin_repo(version, sha256): maybe( @@ -51,13 +38,13 @@ def _rules_kotlin_repo(version, sha256): def io_bazel_rules_kotlin(): _rules_kotlin_repo( - version = "v1.6.0-RC-2", - sha256 = "88d19c92a1fb63fb64ddb278cd867349c3b0d648b6fe9ef9a200b9abcacd489d", + version = "v1.8-RC-12", + sha256 = "8e5c8ab087e0fa3fbb58e1f6b99d8fe40f75bac44994c3d208eba723284465d6", ) def rules_kotlin_maven_artifacts_dict(): artifacts_dict = { coordinates: KOTLIN_RELEASE_VERSION - for coordinates in _JETBRAINS_KOTLIN_OVERRIDE_TARGETS.keys() + for coordinates in _JETBRAINS_KOTLIN_LIBRARIES } return artifacts_dict diff --git a/build/rules_kotlin/toolchain/BUILD.bazel b/build/rules_kotlin/toolchain/BUILD.bazel index e7a1e8ea7..a3ccb3c49 100644 --- a/build/rules_kotlin/toolchain/BUILD.bazel +++ b/build/rules_kotlin/toolchain/BUILD.bazel @@ -7,6 +7,7 @@ load("//build:versions.bzl", "KOTLIN_LANGUAGE_LEVEL") kt_kotlinc_options( name = "default_opts", + include_stdlibs = "none", x_optin = ["kotlin.RequiresOptIn"], ) diff --git a/build/versions.bzl b/build/versions.bzl index 11e303d53..9ce1dfe96 100644 --- a/build/versions.bzl +++ b/build/versions.bzl @@ -104,15 +104,15 @@ RULES_DOCKER = VersionedArchiveInfo( ], ) -KOTLIN_LANGUAGE_LEVEL = "1.5" +KOTLIN_LANGUAGE_LEVEL = "1.7" # Kotlin release version. # # See https://kotlinlang.org/docs/releases.html#release-details. -KOTLIN_RELEASE_VERSION = "1.6.21" +KOTLIN_RELEASE_VERSION = "1.8.21" # kotlinx.coroutines version. -KOTLINX_COROUTINES_VERSION = "1.6.2" +KOTLINX_COROUTINES_VERSION = "1.7.0-RC" # Tink commit that is newer than v1.6.1. # diff --git a/imports/kotlin/kotlin/BUILD.bazel b/imports/kotlin/kotlin/BUILD.bazel index 8a7749f31..971ef2125 100644 --- a/imports/kotlin/kotlin/BUILD.bazel +++ b/imports/kotlin/kotlin/BUILD.bazel @@ -1,11 +1,6 @@ package(default_visibility = ["//visibility:public"]) alias( - name = "stdlib_jdk7", - actual = "@maven//:org_jetbrains_kotlin_kotlin_stdlib_jdk7", -) - -alias( - name = "stdlib_jdk8", - actual = "@maven//:org_jetbrains_kotlin_kotlin_stdlib_jdk8", + name = "stdlib", + actual = "@maven//:org_jetbrains_kotlin_kotlin_stdlib", ) diff --git a/imports/kotlin/kotlin/reflect/jvm/BUILD.bazel b/imports/kotlin/kotlin/reflect/BUILD.bazel similarity index 85% rename from imports/kotlin/kotlin/reflect/jvm/BUILD.bazel rename to imports/kotlin/kotlin/reflect/BUILD.bazel index f9702ab96..eb2c71997 100644 --- a/imports/kotlin/kotlin/reflect/jvm/BUILD.bazel +++ b/imports/kotlin/kotlin/reflect/BUILD.bazel @@ -1,6 +1,6 @@ package(default_visibility = ["//visibility:public"]) alias( - name = "jvm", + name = "reflect", actual = "@maven//:org_jetbrains_kotlin_kotlin_reflect", ) diff --git a/src/main/kotlin/org/wfanet/measurement/aws/postgres/tools/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/aws/postgres/tools/BUILD.bazel index 830b14c55..96cdf47f9 100644 --- a/src/main/kotlin/org/wfanet/measurement/aws/postgres/tools/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/aws/postgres/tools/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/aws/s3/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/aws/s3/BUILD.bazel index 8f111463f..679bd9ace 100644 --- a/src/main/kotlin/org/wfanet/measurement/aws/s3/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/aws/s3/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/BUILD.bazel index c7ccb4c10..54da33b1c 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/BUILD.bazel @@ -1,14 +1,10 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) kt_jvm_library( name = "common", srcs = glob(["*.kt"]), - runtime_deps = [ - "//imports/kotlin/kotlin:stdlib_jdk7", - "//imports/kotlin/kotlin/reflect/jvm", - ], deps = [ "//imports/java/com/google/common:guava", "//imports/java/com/google/devtools/build/runfiles", diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel index ae998bdff..7d8b7285a 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/crypto/testing/BUILD.bazel index cf1107caa..1c08aad45 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package( default_testonly = True, diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel index 79a1735bf..d33fef7a7 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/testing/BUILD.bazel index 9d92d4126..8dccf59e8 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/tink/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package( default_testonly = True, diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/BUILD.bazel index a2b3c3e1a..4bf17bf3d 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/tools/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/tools/BUILD.bazel index 565d093cc..591eb0954 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/tools/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/liquibase/tools/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/postgres/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/postgres/BUILD.bazel index 203e16293..2aa5a1116 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/postgres/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/postgres/BUILD.bazel @@ -1,6 +1,6 @@ # Database specifics for Postgres. -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/postgres/tools/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/postgres/tools/BUILD.bazel index 974e72679..79ac8be60 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/postgres/tools/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/postgres/tools/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/BUILD.bazel index e46d224b2..e45ef5245 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/ReadWriteContext.kt b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/ReadWriteContext.kt index e14549540..c23ee4ffa 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/ReadWriteContext.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/ReadWriteContext.kt @@ -18,7 +18,6 @@ package org.wfanet.measurement.common.db.r2dbc import io.r2dbc.spi.Connection import io.r2dbc.spi.TransactionDefinition -import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.cancellable import kotlinx.coroutines.flow.flatMapConcat import kotlinx.coroutines.flow.fold @@ -41,7 +40,7 @@ interface ReadWriteContext : ReadContext { internal class ReadWriteContextImpl private constructor(connection: Connection) : ReadWriteContext, ReadContextImpl(connection) { - @OptIn(FlowPreview::class) // For `flatMapConcat`. + @OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) // For `flatMapConcat`. override suspend fun executeStatement(statement: BoundStatement): StatementResult { val numRowsUpdated = statement diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/BUILD.bazel index e403029b6..5d2589c25 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/testing/BUILD.bazel index 562d2f87b..9c4f9fd87 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package( default_testonly = True, diff --git a/src/main/kotlin/org/wfanet/measurement/common/graphviz/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/graphviz/BUILD.bazel index 7096224f9..1fe386189 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/graphviz/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/graphviz/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel index da970bc36..cf6a3174a 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/grpc/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/grpc/testing/BUILD.bazel index 7664be0d7..1c3b22af1 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/grpc/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/grpc/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package( default_testonly = True, diff --git a/src/main/kotlin/org/wfanet/measurement/common/identity/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/identity/BUILD.bazel index a01bfcd69..fb27efd64 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/identity/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/identity/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/identity/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/identity/testing/BUILD.bazel index 216cabf28..d2d789c24 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/identity/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/identity/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/openid/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/openid/BUILD.bazel index 17afa9964..1156f803c 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/openid/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/openid/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel index 7cd6b7903..5807505a3 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) @@ -6,11 +6,6 @@ kt_jvm_library( name = "testing", testonly = True, srcs = glob(["*.kt"]), - runtime_deps = [ - # Workaround for `NoClassDefFoundError: kotlin/jdk7/AutoCloseableKt`. - # See https://github.com/bazelbuild/rules_kotlin/issues/333 - "//imports/kotlin/kotlin:stdlib_jdk7", - ], deps = [ "//imports/java/com/google/common/truth", "//imports/java/com/google/common/truth/extensions/proto", diff --git a/src/main/kotlin/org/wfanet/measurement/common/throttler/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/throttler/BUILD.bazel index 479b4646b..79be835a0 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/throttler/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/throttler/BUILD.bazel @@ -1,11 +1,10 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) kt_jvm_library( name = "throttler", srcs = glob(["*.kt"]), - runtime_deps = ["//imports/kotlin/kotlin:stdlib_jdk7"], deps = [ "//imports/java/picocli", "//imports/kotlin/kotlinx/coroutines:core", diff --git a/src/main/kotlin/org/wfanet/measurement/common/throttler/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/throttler/testing/BUILD.bazel index 3745df7f3..cfe0b8ee4 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/throttler/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/throttler/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/common/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/common/BUILD.bazel index f30ad3df7..58123ef7b 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/common/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/common/BUILD.bazel @@ -1,6 +1,6 @@ # Common functionality for Google Cloud (gcloud) APIs. -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/gcs/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/gcs/BUILD.bazel index 6e96d228d..edda91e30 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/gcs/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/gcs/BUILD.bazel @@ -1,6 +1,6 @@ # Blob/object storage specifics for Google Cloud Storage (GCS). -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel index 033c04698..44439c3d5 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel @@ -1,6 +1,6 @@ # Database specifics for Postgres. -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/tools/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/tools/BUILD.bazel index 03e448ceb..9e1177b7f 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/tools/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/tools/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/BUILD.bazel index 96b4177e3..cd8d79509 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/BUILD.bazel @@ -1,6 +1,6 @@ # Database specifics for Google Cloud Spanner. -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/BUILD.bazel index 90ddcf03f..c85a89884 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package( default_testonly = True, diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/tools/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/tools/BUILD.bazel index fa247b0cf..661b54bd2 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/tools/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/tools/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/storage/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/storage/BUILD.bazel index 0be6cf5c8..ba0589096 100644 --- a/src/main/kotlin/org/wfanet/measurement/storage/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/storage/BUILD.bazel @@ -1,6 +1,6 @@ # Blob/object storage. -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel index 67fbecf08..44c2445bf 100644 --- a/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") load("@rules_java//java:defs.bzl", "java_binary") load("@io_bazel_rules_docker//java:image.bzl", "java_image") @@ -23,7 +23,6 @@ kt_jvm_library( ":client", "//imports/java/io/grpc:api", "//imports/java/org/jetbrains/annotations", - "//imports/kotlin/kotlin:stdlib_jdk7", "//imports/kotlin/kotlinx/coroutines:core", "//src/main/kotlin/org/wfanet/measurement/common", "//src/main/kotlin/org/wfanet/measurement/storage:client", diff --git a/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel index 31a4d5913..1d7a9ca1e 100644 --- a/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/storage/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/storage/testing/BUILD.bazel index 35ee9c63c..e7ace31d1 100644 --- a/src/main/kotlin/org/wfanet/measurement/storage/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/storage/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package( default_testonly = True, diff --git a/src/test/kotlin/org/wfanet/measurement/common/BUILD.bazel b/src/test/kotlin/org/wfanet/measurement/common/BUILD.bazel index d096c79a8..981b6ef14 100644 --- a/src/test/kotlin/org/wfanet/measurement/common/BUILD.bazel +++ b/src/test/kotlin/org/wfanet/measurement/common/BUILD.bazel @@ -49,7 +49,6 @@ kt_jvm_test( deps = [ "//imports/java/com/google/common/truth", "//imports/java/org/junit", - "//imports/kotlin/kotlin:stdlib_jdk7", "//imports/kotlin/kotlin/test", "//imports/kotlin/kotlinx/coroutines:core", "//imports/kotlin/kotlinx/coroutines/test", From 03fba143e8c721d101cee0b0893b87a785ad6463 Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Tue, 12 Sep 2023 16:57:12 -0700 Subject: [PATCH 2/7] Update rules_kotlin to 1.8.1 and kotlinx.coroutines to 1.7.3. --- build/rules_kotlin/repo.bzl | 22 +++++++--------------- build/versions.bzl | 12 ++++++++++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build/rules_kotlin/repo.bzl b/build/rules_kotlin/repo.bzl index 24dc60c0b..0738622fa 100644 --- a/build/rules_kotlin/repo.bzl +++ b/build/rules_kotlin/repo.bzl @@ -17,9 +17,12 @@ See https://github.com/bazelbuild/rules_kotlin """ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("//build:versions.bzl", "KOTLIN_RELEASE_VERSION") +load( + "//build:versions.bzl", + "KOTLIN_RELEASE_VERSION", + "RULES_KOTLIN", + "versioned_http_archive", +) _JETBRAINS_KOTLIN_LIBRARIES = [ "org.jetbrains.kotlin:kotlin-stdlib", @@ -28,19 +31,8 @@ _JETBRAINS_KOTLIN_LIBRARIES = [ "org.jetbrains.kotlin:kotlin-test", ] -def _rules_kotlin_repo(version, sha256): - maybe( - http_archive, - name = "io_bazel_rules_kotlin", - urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % version], - sha256 = sha256, - ) - def io_bazel_rules_kotlin(): - _rules_kotlin_repo( - version = "v1.8-RC-12", - sha256 = "8e5c8ab087e0fa3fbb58e1f6b99d8fe40f75bac44994c3d208eba723284465d6", - ) + versioned_http_archive(RULES_KOTLIN, "io_bazel_rules_kotlin") def rules_kotlin_maven_artifacts_dict(): artifacts_dict = { diff --git a/build/versions.bzl b/build/versions.bzl index 9ce1dfe96..49b041ab6 100644 --- a/build/versions.bzl +++ b/build/versions.bzl @@ -104,7 +104,15 @@ RULES_DOCKER = VersionedArchiveInfo( ], ) -KOTLIN_LANGUAGE_LEVEL = "1.7" +RULES_KOTLIN = VersionedArchiveInfo( + version = "1.8.1", + sha256 = "a630cda9fdb4f56cf2dc20a4bf873765c41cf00e9379e8d59cd07b24730f4fde", + url_templates = [ + "https://github.com/bazelbuild/rules_kotlin/releases/download/v{version}/rules_kotlin_release.tgz", + ], +) + +KOTLIN_LANGUAGE_LEVEL = "1.8" # Kotlin release version. # @@ -112,7 +120,7 @@ KOTLIN_LANGUAGE_LEVEL = "1.7" KOTLIN_RELEASE_VERSION = "1.8.21" # kotlinx.coroutines version. -KOTLINX_COROUTINES_VERSION = "1.7.0-RC" +KOTLINX_COROUTINES_VERSION = "1.7.3" # Tink commit that is newer than v1.6.1. # From c650ca047e76429c80c7a509d22c6d0981588b5d Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Mon, 26 Jun 2023 17:30:53 -0700 Subject: [PATCH 3/7] Fix warning for ReceiveChannel.isClosedForReceive. --- .../org/wfanet/measurement/common/Flow.kt | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/org/wfanet/measurement/common/Flow.kt b/src/main/kotlin/org/wfanet/measurement/common/Flow.kt index 36f62d726..ebd2aeccb 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/Flow.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/Flow.kt @@ -17,13 +17,12 @@ package org.wfanet.measurement.common import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.async import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.channels.ClosedReceiveChannelException +import kotlinx.coroutines.channels.ChannelResult import kotlinx.coroutines.channels.ReceiveChannel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.buffer @@ -151,8 +150,7 @@ private class SingleConsumedFlowItem(singleItem: T) : ConsumedFlowItem() { * [ConsumedFlowItem.close]. */ @OptIn( - FlowPreview::class, // For `produceIn` - ExperimentalCoroutinesApi::class // For `Channel.isClosedForReceive`. + DelicateCoroutinesApi::class // For `Channel.isClosedForReceive`. ) suspend fun Flow.consumeFirst( producerContext: CoroutineContext = Dispatchers.Unconfined @@ -163,17 +161,15 @@ suspend fun Flow.consumeFirst( // We can't know whether the flow is empty until we start collecting. Since // we're using a rendezvous channel, this means the channel won't be closed // until after we attempt to receive the first item. - val item = - try { - channel.receive() - } catch (e: ClosedReceiveChannelException) { - producerScope.cancel() - return null - } + val result: ChannelResult = channel.receiveCatching() + if (result.isClosed) { + producerScope.cancel() + return null + } val hasRemaining = !channel.isClosedForReceive return object : ConsumedFlowItem() { - override val item = item + override val item = result.getOrThrow() override val remaining = if (hasRemaining) channel.consumeAsFlow() else flowOf() override val hasRemaining = hasRemaining From c49e4de208de7b910b4ffbcf59004ed20c4024ac Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Tue, 12 Sep 2023 17:03:16 -0700 Subject: [PATCH 4/7] Add wrapper macro for kt_jvm_library with stdlib. --- build/grpc_kotlin/repo.bzl | 3 ++- build/kt_jvm_proto/defs.bzl | 9 +++++--- build/rules_kotlin/defs.bzl | 23 +++++++++++++------ imports/kotlin/io/grpc/kotlin/BUILD.bazel | 5 ++++ imports/kotlin/kotlinx/coroutines/BUILD.bazel | 9 ++++++-- .../wfanet/measurement/aws/common/BUILD.bazel | 2 +- .../measurement/aws/postgres/BUILD.bazel | 2 +- .../measurement/common/crypto/BUILD.bazel | 1 + .../measurement/common/grpc/BUILD.bazel | 3 +++ .../measurement/common/riegeli/BUILD.bazel | 2 +- .../measurement/common/testing/BUILD.bazel | 2 ++ .../storage/filesystem/BUILD.bazel | 1 + .../measurement/storage/forwarded/BUILD.bazel | 2 ++ .../common/crypto/tink/BUILD.bazel | 2 ++ .../measurement/common/grpc/BUILD.bazel | 4 ++++ .../measurement/common/testing/BUILD.bazel | 1 + 16 files changed, 55 insertions(+), 16 deletions(-) diff --git a/build/grpc_kotlin/repo.bzl b/build/grpc_kotlin/repo.bzl index 6c7cddcf0..1ef782925 100644 --- a/build/grpc_kotlin/repo.bzl +++ b/build/grpc_kotlin/repo.bzl @@ -18,9 +18,10 @@ Repository rules/macros for Github GPRC Kotlin. load("//build:versions.bzl", "GRPC_KOTLIN", "versioned_http_archive") -# kt_jvm_grpc_library directly depends on the stub library target below. +# kt_jvm_grpc_library directly depends on these library targets. GRPC_KOTLIN_OVERRIDE_TARGETS = { "io.grpc:grpc-kotlin-stub": "@com_github_grpc_grpc_kotlin//stub/src/main/java/io/grpc/kotlin:stub", + "io.grpc:grpc-kotlin-context": "@com_github_grpc_grpc_kotlin//stub/src/main/java/io/grpc/kotlin:context", } def com_github_grpc_grpc_kotlin(): diff --git a/build/kt_jvm_proto/defs.bzl b/build/kt_jvm_proto/defs.bzl index 0240b1635..af2c0debb 100644 --- a/build/kt_jvm_proto/defs.bzl +++ b/build/kt_jvm_proto/defs.bzl @@ -153,6 +153,10 @@ _kt_jvm_proto_library_helper = rule( implementation = _kt_jvm_proto_library_helper_impl, ) +_KT_JVM_PROTO_DEPS = [ + "@com_google_protobuf_protobuf_kotlin", +] + def kt_jvm_proto_library(name, srcs = None, deps = None, **kwargs): """Generates Kotlin code for a protocol buffer library. @@ -186,9 +190,8 @@ def kt_jvm_proto_library(name, srcs = None, deps = None, **kwargs): kt_jvm_library( name = name, srcs = [generated_srcjar], - # TODO: add Bazel rule in protobuf instead of relying on Maven - deps = deps + ["@maven//:com_google_protobuf_protobuf_kotlin"], - exports = deps, + deps = deps + _KT_JVM_PROTO_DEPS, + exports = deps + _KT_JVM_PROTO_DEPS, kotlinc_opts = "@wfa_common_jvm//build/kt_jvm_proto:proto_gen_kt_options", **kwargs ) diff --git a/build/rules_kotlin/defs.bzl b/build/rules_kotlin/defs.bzl index 7fc575110..1010eda63 100644 --- a/build/rules_kotlin/defs.bzl +++ b/build/rules_kotlin/defs.bzl @@ -14,14 +14,23 @@ """Macros for kt_jvm_library to include Maven kotlin stdlib.""" -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", old_kt_jvm_library = "kt_jvm_library") +load( + "@io_bazel_rules_kotlin//kotlin:jvm.bzl", + _kt_jvm_library = "kt_jvm_library", +) -def kt_jvm_library(name, deps = [], **kwargs): - old_kt_jvm_library( +_STDLIBS = [ + "@wfa_common_jvm//imports/kotlin/kotlin:stdlib", + "@wfa_common_jvm//imports/kotlin/kotlin/reflect", +] + +def kt_jvm_library(name, deps = None, exports = None, **kwargs): + deps = deps or [] + exports = exports or [] + + _kt_jvm_library( name = name, - deps = [ - "//imports/kotlin/kotlin:stdlib", - "//imports/kotlin/kotlin/reflect", - ] + deps, + deps = deps + _STDLIBS, + exports = exports + _STDLIBS, **kwargs ) diff --git a/imports/kotlin/io/grpc/kotlin/BUILD.bazel b/imports/kotlin/io/grpc/kotlin/BUILD.bazel index bd5cee8fb..905040fa8 100644 --- a/imports/kotlin/io/grpc/kotlin/BUILD.bazel +++ b/imports/kotlin/io/grpc/kotlin/BUILD.bazel @@ -4,3 +4,8 @@ alias( name = "stub", actual = "@maven//:io_grpc_grpc_kotlin_stub", ) + +alias( + name = "context", + actual = "@maven//:io_grpc_grpc_kotlin_context", +) diff --git a/imports/kotlin/kotlinx/coroutines/BUILD.bazel b/imports/kotlin/kotlinx/coroutines/BUILD.bazel index ca1ff5a0c..aef4323dd 100644 --- a/imports/kotlin/kotlinx/coroutines/BUILD.bazel +++ b/imports/kotlin/kotlinx/coroutines/BUILD.bazel @@ -1,8 +1,13 @@ +load("@rules_java//java:defs.bzl", "java_library") + package(default_visibility = ["//visibility:public"]) -alias( +java_library( name = "core", - actual = "@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core", + exports = [ + "@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core", + "@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm", + ], ) alias( diff --git a/src/main/kotlin/org/wfanet/measurement/aws/common/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/aws/common/BUILD.bazel index 102865656..25a6bd195 100644 --- a/src/main/kotlin/org/wfanet/measurement/aws/common/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/aws/common/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/aws/postgres/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/aws/postgres/BUILD.bazel index 551ab3bf2..d4020e99a 100644 --- a/src/main/kotlin/org/wfanet/measurement/aws/postgres/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/aws/postgres/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel index 7d8b7285a..3c4f0c86e 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/BUILD.bazel @@ -106,6 +106,7 @@ kt_jvm_library( ":pem_io", ":security_provider", ":signing_key_storage", + "//imports/java/com/google/protobuf", "//src/main/kotlin/org/wfanet/measurement/common", ], ) diff --git a/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel index cf6a3174a..2c1513d32 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel @@ -8,10 +8,13 @@ kt_jvm_library( deps = [ "//imports/java/com/google/protobuf", "//imports/java/io/grpc:api", + "//imports/java/io/grpc:context", "//imports/java/io/grpc/netty", "//imports/java/io/grpc/protobuf/services", + "//imports/java/io/netty/handler", "//imports/java/org/jetbrains/annotations", "//imports/java/picocli", + "//imports/kotlin/io/grpc/kotlin:context", "//imports/kotlin/io/grpc/kotlin:stub", "//imports/kotlin/kotlinx/coroutines:core", "//src/main/kotlin/org/wfanet/measurement/common", diff --git a/src/main/kotlin/org/wfanet/measurement/common/riegeli/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/riegeli/BUILD.bazel index b4d0f11b5..71e786335 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/riegeli/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/riegeli/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("//build/rules_kotlin:defs.bzl", "kt_jvm_library") package(default_visibility = ["//visibility:public"]) diff --git a/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel index 5807505a3..5b4a0ef30 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel @@ -10,7 +10,9 @@ kt_jvm_library( "//imports/java/com/google/common/truth", "//imports/java/com/google/common/truth/extensions/proto", "//imports/java/com/google/protobuf", + "//imports/java/io/grpc:api", "//imports/java/org/junit", + "//imports/java/org/mockito", "//imports/kotlin/kotlinx/coroutines:core", "//imports/kotlin/kotlinx/coroutines:jdk8", "//imports/kotlin/org/mockito/kotlin", diff --git a/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel index 44c2445bf..ea66d4b38 100644 --- a/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/storage/filesystem/BUILD.bazel @@ -38,6 +38,7 @@ kt_jvm_library( deps = [ ":service", "//imports/java/picocli", + "//imports/kotlin/kotlinx/coroutines:core", "//src/main/kotlin/org/wfanet/measurement/common", "//src/main/kotlin/org/wfanet/measurement/common/grpc", ], diff --git a/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel index 1d7a9ca1e..6cbd7f19a 100644 --- a/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/storage/forwarded/BUILD.bazel @@ -10,6 +10,8 @@ kt_jvm_library( "//imports/java/io/grpc:api", "//imports/java/picocli", "//imports/kotlin/kotlinx/coroutines:core", + "//src/main/kotlin/org/wfanet/measurement/common", + "//src/main/kotlin/org/wfanet/measurement/common/crypto:pem_io", "//src/main/kotlin/org/wfanet/measurement/common/grpc", "//src/main/kotlin/org/wfanet/measurement/storage:client", "//src/main/proto/wfa/measurement/internal/testing:forwarded_storage_service_kt_jvm_grpc_proto", diff --git a/src/test/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel b/src/test/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel index d71c87e18..8469c6072 100644 --- a/src/test/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel +++ b/src/test/kotlin/org/wfanet/measurement/common/crypto/tink/BUILD.bazel @@ -5,7 +5,9 @@ kt_jvm_test( srcs = ["KeyHandleTest.kt"], deps = [ "//imports/java/com/google/common/truth", + "//imports/java/com/google/protobuf", "//imports/java/org/junit", + "//imports/kotlin/com/google/protobuf/kotlin", "//src/main/kotlin/org/wfanet/measurement/common/crypto/testing", "//src/main/kotlin/org/wfanet/measurement/common/crypto/tink", "//src/main/kotlin/org/wfanet/measurement/common/crypto/tink/testing", diff --git a/src/test/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel b/src/test/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel index 331f960e0..b7c4e7eba 100644 --- a/src/test/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel +++ b/src/test/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel @@ -6,6 +6,7 @@ kt_jvm_test( test_class = "org.wfanet.measurement.common.grpc.ChannelShutdownHookTest", deps = [ "//imports/java/com/google/common/truth", + "//imports/java/io/grpc:api", "//imports/java/io/grpc:core", "//imports/java/io/grpc/testing", "//imports/java/org/junit", @@ -25,9 +26,11 @@ kt_jvm_test( test_class = "org.wfanet.measurement.common.grpc.TransportSecurityTest", deps = [ "//imports/java/com/google/common/truth", + "//imports/java/io/grpc:api", "//imports/java/io/grpc/netty", "//imports/java/io/grpc/protobuf/services", "//imports/java/io/grpc/testing", + "//imports/java/io/netty/handler", "//imports/java/org/junit", "//imports/kotlin/io/grpc/health/v1:health_kt_jvm_grpc", "//imports/kotlin/kotlin/test", @@ -42,6 +45,7 @@ kt_jvm_test( test_class = "org.wfanet.measurement.common.grpc.PreconditionsTest", deps = [ "//imports/java/com/google/common/truth", + "//imports/java/io/grpc:api", "//imports/java/io/grpc/testing", "//imports/java/org/junit", "//imports/kotlin/kotlin/test", diff --git a/src/test/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel b/src/test/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel index 3e6996434..eff5570dd 100644 --- a/src/test/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel +++ b/src/test/kotlin/org/wfanet/measurement/common/testing/BUILD.bazel @@ -21,6 +21,7 @@ kt_jvm_test( "//imports/java/org/junit", "//imports/java/picocli", "//imports/kotlin/kotlin/test", + "//src/main/kotlin/org/wfanet/measurement/common", "//src/main/kotlin/org/wfanet/measurement/common/testing", ], ) From 2e1ca87be1669912cb0322643e6f6672645b3458 Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Mon, 21 Aug 2023 09:04:59 -0700 Subject: [PATCH 5/7] Drop references to nonexistant grpc-kotlin-context Maven artifact. --- build/grpc_kotlin/repo.bzl | 1 - imports/kotlin/io/grpc/kotlin/BUILD.bazel | 5 ----- .../kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel | 1 - 3 files changed, 7 deletions(-) diff --git a/build/grpc_kotlin/repo.bzl b/build/grpc_kotlin/repo.bzl index 1ef782925..a4898870a 100644 --- a/build/grpc_kotlin/repo.bzl +++ b/build/grpc_kotlin/repo.bzl @@ -21,7 +21,6 @@ load("//build:versions.bzl", "GRPC_KOTLIN", "versioned_http_archive") # kt_jvm_grpc_library directly depends on these library targets. GRPC_KOTLIN_OVERRIDE_TARGETS = { "io.grpc:grpc-kotlin-stub": "@com_github_grpc_grpc_kotlin//stub/src/main/java/io/grpc/kotlin:stub", - "io.grpc:grpc-kotlin-context": "@com_github_grpc_grpc_kotlin//stub/src/main/java/io/grpc/kotlin:context", } def com_github_grpc_grpc_kotlin(): diff --git a/imports/kotlin/io/grpc/kotlin/BUILD.bazel b/imports/kotlin/io/grpc/kotlin/BUILD.bazel index 905040fa8..bd5cee8fb 100644 --- a/imports/kotlin/io/grpc/kotlin/BUILD.bazel +++ b/imports/kotlin/io/grpc/kotlin/BUILD.bazel @@ -4,8 +4,3 @@ alias( name = "stub", actual = "@maven//:io_grpc_grpc_kotlin_stub", ) - -alias( - name = "context", - actual = "@maven//:io_grpc_grpc_kotlin_context", -) diff --git a/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel index 2c1513d32..f87d30170 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/common/grpc/BUILD.bazel @@ -14,7 +14,6 @@ kt_jvm_library( "//imports/java/io/netty/handler", "//imports/java/org/jetbrains/annotations", "//imports/java/picocli", - "//imports/kotlin/io/grpc/kotlin:context", "//imports/kotlin/io/grpc/kotlin:stub", "//imports/kotlin/kotlinx/coroutines:core", "//src/main/kotlin/org/wfanet/measurement/common", From a75632e463590fc9c21397c4096b9a8f138e6d62 Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Tue, 12 Sep 2023 17:18:07 -0700 Subject: [PATCH 6/7] Remove unused OptIn. --- .../kotlin/org/wfanet/measurement/common/crypto/DerEncoding.kt | 1 - .../kotlin/org/wfanet/measurement/common/crypto/Signatures.kt | 1 - .../org/wfanet/measurement/common/db/r2dbc/QueryResult.kt | 1 - .../measurement/common/db/r2dbc/postgres/SerializableErrors.kt | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/DerEncoding.kt b/src/main/kotlin/org/wfanet/measurement/common/crypto/DerEncoding.kt index adbbb3630..bd76b09b9 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/DerEncoding.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/DerEncoding.kt @@ -33,7 +33,6 @@ private enum class Asn1TagClass { PRIVATE; companion object { - @OptIn(ExperimentalUnsignedTypes::class) fun fromIdentifier(octet: Byte): Asn1TagClass = when (val tagClass = octet.toUByte().toInt() ushr 6) { 0 -> UNIVERSAL diff --git a/src/main/kotlin/org/wfanet/measurement/common/crypto/Signatures.kt b/src/main/kotlin/org/wfanet/measurement/common/crypto/Signatures.kt index f954e3b47..9ca3c9043 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/crypto/Signatures.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/crypto/Signatures.kt @@ -26,7 +26,6 @@ import java.security.cert.X509Certificate import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Deferred import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.onEach diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/QueryResult.kt b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/QueryResult.kt index 44ce3432a..cb6c00aaf 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/QueryResult.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/QueryResult.kt @@ -75,7 +75,6 @@ class ResultRow(private val delegate: Row) { } @Suppress("EXTENSION_SHADOWED_BY_MEMBER") -@OptIn(ExperimentalStdlibApi::class) // For `typeOf`. inline operator fun Readable.get(name: String): T { val value = get(name, T::class) if (value == null) { diff --git a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/SerializableErrors.kt b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/SerializableErrors.kt index e28a191ef..70fa3bb1a 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/SerializableErrors.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/SerializableErrors.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.single object SerializableErrors { private const val SERIALIZABLE_ERROR_CODE = "40001" - @OptIn(ExperimentalTime::class) private val SERIALIZABLE_RETRY_DURATION = 120.seconds + private val SERIALIZABLE_RETRY_DURATION = 120.seconds suspend fun retrying(block: suspend () -> T): T { return flow { emit(block()) }.withSerializableErrorRetries().single() From 3a59e8f2502b96f200436c885beda84c9bdad6b0 Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Tue, 12 Sep 2023 17:21:46 -0700 Subject: [PATCH 7/7] Fix unresolved reference in KDoc caused by bad formatting. --- src/main/kotlin/org/wfanet/measurement/common/Flow.kt | 4 ++-- .../wfanet/measurement/common/testing/CloseableResource.kt | 4 ++-- .../gcloud/spanner/testing/UsingSpannerEmulator.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/org/wfanet/measurement/common/Flow.kt b/src/main/kotlin/org/wfanet/measurement/common/Flow.kt index ebd2aeccb..1a28e4db3 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/Flow.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/Flow.kt @@ -146,8 +146,8 @@ private class SingleConsumedFlowItem(singleItem: T) : ConsumedFlowItem() { * * @param producerContext [CoroutineContext] for producing the returned items * @return a [ConsumedFlowItem] containing the first item and the [Flow] of remaining items, or - * `null` if there is no first item. The caller must ensure that the returned object is [closed] - * [ConsumedFlowItem.close]. + * `null` if there is no first item. The caller must ensure that the returned object is + * [closed][ConsumedFlowItem.close]. */ @OptIn( DelicateCoroutinesApi::class // For `Channel.isClosedForReceive`. diff --git a/src/main/kotlin/org/wfanet/measurement/common/testing/CloseableResource.kt b/src/main/kotlin/org/wfanet/measurement/common/testing/CloseableResource.kt index abe38adaa..906dd4d33 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/testing/CloseableResource.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/testing/CloseableResource.kt @@ -23,8 +23,8 @@ import org.junit.runners.model.Statement * evaluation. * * This can replace [ExternalResource][org.junit.rules.ExternalResource], which does not guarantee - * that [after][org.junit.rules.ExternalResource.after] is invoked if [before] - * [org.junit.rules.ExternalResource.before] throws an exception. + * that [after][org.junit.rules.ExternalResource.after] is invoked if + * [before][org.junit.rules.ExternalResource.before] throws an exception. */ open class CloseableResource(private val createResource: () -> T) : TestRule { protected lateinit var resource: T diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/UsingSpannerEmulator.kt b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/UsingSpannerEmulator.kt index 58f4ee3b8..e64df3788 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/UsingSpannerEmulator.kt +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/spanner/testing/UsingSpannerEmulator.kt @@ -19,8 +19,8 @@ import org.junit.Rule import org.wfanet.measurement.gcloud.spanner.AsyncDatabaseClient /** - * Base class for JUnit4 tests using Cloud Spanner databases running in a test [Instance] - * [com.google.cloud.spanner.Instance] in Cloud Spanner Emulator. + * Base class for JUnit4 tests using Cloud Spanner databases running in a test + * [Instance][com.google.cloud.spanner.Instance] in Cloud Spanner Emulator. * * One emulator and test instance is created per test class, and one database is created per test * case method. The [AsyncDatabaseClient] is accessible via the [databaseClient] property.