diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 18009d5b2..5323fe741 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -13,16 +13,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_java", - patch_args = ["-p1"], - patches = [ - # https://github.com/bazelbuild/rules_java/pull/114 - # Remove unnecessary dependency on a Java runtime for the target platform. - "//third_party:rules_java-use-bootstrap-runtime-toolchain-type.patch", - ], - sha256 = "fd1d5538c8e5bbf890e1e31e983139b89710aacd0a5327ddf9afe12090ed9c78", - strip_prefix = "rules_java-ca72739da10036e1d2cf2aaeab78fae87673e43f", + sha256 = "7b0d9ba216c821ee8697dedc0f9d0a705959ace462a3885fe9ba0347ba950111", urls = [ - "https://github.com/bazelbuild/rules_java/archive/ca72739da10036e1d2cf2aaeab78fae87673e43f.tar.gz", + "https://github.com/bazelbuild/rules_java/releases/download/6.5.1/rules_java-6.5.1.tar.gz", ], ) @@ -94,14 +87,9 @@ http_archive( http_archive( name = "contrib_rules_jvm", - patch_args = ["-p1"], - patches = [ - # https://github.com/bazel-contrib/rules_jvm/pull/194 - "//third_party:rules_jvm-fix-junit5-for-early-access-builds.patch", - ], - sha256 = "90ecdf08d7e8817b2247eea77826db872db8866da84b3a824f58d6661aca917f", - strip_prefix = "rules_jvm-0.14.0", - url = "https://github.com/bazel-contrib/rules_jvm/releases/download/v0.14.0/rules_jvm-v0.14.0.tar.gz", + sha256 = "4d62589dc6a55e74bbe33930b826d593367fc777449a410604b2ad7c6c625ef7", + strip_prefix = "rules_jvm-0.19.0", + url = "https://github.com/bazel-contrib/rules_jvm/releases/download/v0.19.0/rules_jvm-v0.19.0.tar.gz", ) http_archive( diff --git a/repositories.bzl b/repositories.bzl index 6662cef53..ef47ef2f1 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -43,17 +43,8 @@ def jazzer_dependencies(android = False): maybe( http_archive, name = "io_bazel_rules_kotlin", - patch_args = ["-p1"], - patches = [ - # https://github.com/bazelbuild/rules_kotlin/pull/1000 - # Remove unnecessary dependency on a Java runtime for the target platform. - "//third_party:rules_kotlin-remove-java-runtime-dep.patch", - # https://github.com/bazelbuild/rules_kotlin/pull/1005 - # Required for compatibility with recent Bazel 7 pre-releases. - "//third_party:rules_kotlin-remove-java-info-transitive-deps.patch", - ], - sha256 = "01293740a16e474669aba5b5a1fe3d368de5832442f164e4fbfc566815a8bc3a", - url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.8/rules_kotlin_release.tgz", + sha256 = "a630cda9fdb4f56cf2dc20a4bf873765c41cf00e9379e8d59cd07b24730f4fde", + url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.8.1/rules_kotlin_release.tgz", ) maybe( @@ -61,25 +52,21 @@ def jazzer_dependencies(android = False): name = "rules_jvm_external", patch_args = ["-p1"], patches = [ - # https://github.com/bazelbuild/rules_jvm_external/pull/958 - # Allows javadoc targets to reference other javadoc targets. - "//third_party:rules_jvm_external-javadoc-deps.patch", # https://github.com/bazelbuild/rules_jvm_external/pull/960 # Forwards the toolchains attribute on java_export to all underlying targets and # evaluates Make variables from deps in pom_file. "//third_party:rules_jvm_external-toolchains-attribute.patch", ], - sha256 = "aa17db9b810b22e411bf722095be34eeb66c76819b9c3423ad7740f452016aa3", - strip_prefix = "rules_jvm_external-4b073de468eff9741406f475acb04e94bee7c9d0", - url = "https://github.com/bazelbuild/rules_jvm_external/archive/4b073de468eff9741406f475acb04e94bee7c9d0.tar.gz", + sha256 = "4ff84d5734b1dfbc1b25819f65f66d4f0c990c0a6ee2b72f20dfd098cf8303bf", + strip_prefix = "rules_jvm_external-d0cfd9d293f37a600eb380bb4b1a7ce751472429", + url = "https://github.com/bazelbuild/rules_jvm_external/archive/d0cfd9d293f37a600eb380bb4b1a7ce751472429.tar.gz", ) maybe( http_archive, name = "build_bazel_apple_support", - sha256 = "ce80afe548fd71ef27b48cb48a283ca21256a0900caec3c7ed9416241e000bfe", - strip_prefix = "apple_support-dab92884a6f031e63ac263e5de8a02f13ac42508", - url = "https://github.com/bazelbuild/apple_support/archive/dab92884a6f031e63ac263e5de8a02f13ac42508.tar.gz", + sha256 = "62cb8c6658739d22986bbe4b025fe9f0f42cce91394096dc85d64b120ccde229", + url = "https://github.com/bazelbuild/apple_support/releases/download/1.10.1/apple_support.1.10.1.tar.gz", ) maybe( @@ -93,9 +80,9 @@ def jazzer_dependencies(android = False): maybe( http_archive, name = "com_github_johnynek_bazel_jar_jar", - sha256 = "85260ebdaf86cf0ce6d0d0f0a3268a09f628c815513141a6b99a023116523f96", - strip_prefix = "bazel_jar_jar-78c8c13ff437e8397ffe80c9a4c905376720a339", - url = "https://github.com/bazeltools/bazel_jar_jar/archive/78c8c13ff437e8397ffe80c9a4c905376720a339.tar.gz", + sha256 = "7487df7cf64ef85bdd5ffc6a0aff92c46ff7550a663c41b262d53f9dc90cd53d", + strip_prefix = "bazel_jar_jar-4e7bf26da8bc8c955578fd8c8a2c763757d344df", + url = "https://github.com/bazeltools/bazel_jar_jar/archive/4e7bf26da8bc8c955578fd8c8a2c763757d344df.tar.gz", ) maybe( diff --git a/third_party/rules_java-use-bootstrap-runtime-toolchain-type.patch b/third_party/rules_java-use-bootstrap-runtime-toolchain-type.patch deleted file mode 100644 index 53ea8d978..000000000 --- a/third_party/rules_java-use-bootstrap-runtime-toolchain-type.patch +++ /dev/null @@ -1,313 +0,0 @@ -From 94f42bb23139a34acda5a0230f7db87bc32c9cf2 Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Fri, 9 Jun 2023 09:48:21 +0200 -Subject: [PATCH 1/4] Obtain bootstrap class path from dedicated runtime - toolchain type - -This decouples the concepts of a Java runtime used to run on the target -platform from the Java runtime that provides the bootstrap class path -used during compilation. - -The former needs constraints on the target platform, whereas the latter -should not have any constraints on the target platform to allow for -cross-compilation to target platforms for which a JDK runtime is not -available (e.g. Android). - -Work towards #17085 -Work towards https://github.com/bazelbuild/rules_java/issues/64 -Split off from #18262 ---- - toolchains/BUILD | 49 ++++++++++++++++++++++++--- - toolchains/default_java_toolchain.bzl | 27 +++++++-------- - toolchains/local_java_repository.bzl | 12 +++++++ - toolchains/remote_java_repository.bzl | 10 ++++++ - 4 files changed, 80 insertions(+), 18 deletions(-) - -diff --git a/toolchains/BUILD b/toolchains/BUILD -index b8cb35d..b208e7b 100644 ---- a/toolchains/BUILD -+++ b/toolchains/BUILD -@@ -29,14 +29,56 @@ filegroup( - srcs = glob(["*.bzl"]), - ) - --# Used to distinguish toolchains used for Java development, ie the JavaToolchainProvider. -+# A single binary distribution of a JDK (e.g., OpenJDK 17 for Windows arm64) provides three -+# different types of toolchains from the perspective of Bazel: -+ -+# The compilation toolchain, which provides the Java runtime used to execute the Java compiler, as -+# well as various helper tools and settings. -+# -+# Toolchains of this type typically have constraints on the execution platform so that their Java -+# runtime can run the compiler, but not on the target platform as Java compilation outputs are -+# platform independent. -+# -+# Obtain the associated JavaToolchainInfo via: -+# ctx.toolchains["@bazel_tools//tools/jdk:toolchain_type"].java - # TODO: migrate away from using @bazel_tools//tools/jdk:toolchain_type ? - # toolchain_type(name = "toolchain_type") - --# Used to distinguish toolchains used for Java execution, ie the JavaRuntimeInfo. -+# The Java runtime that executable Java compilation outputs (e.g., java_binary with -+# create_executable = True) will run on. -+# -+# Toolchains of this type typically have constraints on the target platform so that the runtime's -+# native 'java' binary can be run there, but not on the execution platform as building an executable -+# Java target only requires copying or symlinking the runtime, which can be done on any platform. -+# -+# Obtain the associated JavaRuntimeInfo via: -+# ctx.toolchains["@bazel_tools//tools/jdk:runtime_toolchain_type"].java_runtime - # TODO: migrate away from using @bazel_tools//tools/jdk:runtime_toolchain_type ? - # toolchain_type(name = "runtime_toolchain_type") - -+# The Java runtime to extract the bootclasspath from that is then used to compile Java sources. -+# -+# As the bootclasspath is platform independent, toolchains of this type may have no constraints. -+# Purely as an optimization to prevent unnecessary fetches of remote runtimes for other -+# architectures, toolchains of this type may have constraints on the execution platform that match -+# those on the corresponding compilation toolchain. -+# -+# Toolchains of this type are only consumed internally by the bootclasspath rule and should not be -+# accessed from Starlark. -+# TODO: migrate away from using @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type ? -+# toolchain_type(name = "bootstrap_runtime_toolchain_type") -+ -+# The Java runtime to extract the bootclasspath from that is then used to compile Java sources. -+# -+# As the bootclasspath is platform independent, toolchains of this type may have no constraints. -+# Purely as an optimization to prevent unnecessary fetches of remote runtimes for other -+# architectures, toolchains of this type may have constraints on the execution platform that match -+# those on the corresponding compilation toolchain. -+# -+# Toolchains of this type are only consumed internally by the bootclasspath rule and should not be -+# accessed from Starlark. -+# toolchain_type(name = "bootstrap_runtime_toolchain_type") -+ - # Points to toolchain[":runtime_toolchain_type"] (was :legacy_current_java_runtime) - java_runtime_alias(name = "current_java_runtime") - -@@ -201,8 +243,7 @@ alias( - bootclasspath( - name = "platformclasspath", - src = "DumpPlatformClassPath.java", -- host_javabase = ":current_java_runtime", -- target_javabase = ":current_java_runtime", -+ java_runtime_alias = ":current_java_runtime", - ) - - default_java_toolchain( -diff --git a/toolchains/default_java_toolchain.bzl b/toolchains/default_java_toolchain.bzl -index 846302e..e696988 100644 ---- a/toolchains/default_java_toolchain.bzl -+++ b/toolchains/default_java_toolchain.bzl -@@ -204,8 +204,10 @@ def java_runtime_files(name, srcs): - tags = ["manual"], - ) - -+_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type") -+ - def _bootclasspath_impl(ctx): -- host_javabase = ctx.attr.host_javabase[java_common.JavaRuntimeInfo] -+ exec_javabase = ctx.attr.java_runtime_alias[java_common.JavaRuntimeInfo] - - class_dir = ctx.actions.declare_directory("%s_classes" % ctx.label.name) - -@@ -220,17 +222,15 @@ def _bootclasspath_impl(ctx): - args.add(ctx.file.src) - - ctx.actions.run( -- executable = "%s/bin/javac" % host_javabase.java_home, -+ executable = "%s/bin/javac" % exec_javabase.java_home, - mnemonic = "JavaToolchainCompileClasses", -- inputs = [ctx.file.src] + ctx.files.host_javabase, -+ inputs = [ctx.file.src] + ctx.files.java_runtime_alias, - outputs = [class_dir], - arguments = [args], - ) - - bootclasspath = ctx.outputs.output_jar - -- inputs = [class_dir] + ctx.files.host_javabase -- - args = ctx.actions.args() - args.add("-XX:+IgnoreUnrecognizedVMOptions") - args.add("--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED") -@@ -240,16 +240,17 @@ def _bootclasspath_impl(ctx): - args.add("DumpPlatformClassPath") - args.add(bootclasspath) - -+ any_javabase = ctx.toolchains[_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE].java_runtime -+ args.add(any_javabase.java_home) -+ - system_files = ("release", "modules", "jrt-fs.jar") -- system = [f for f in ctx.files.target_javabase if f.basename in system_files] -+ system = [f for f in any_javabase.files.to_list() if f.basename in system_files] - if len(system) != len(system_files): - system = None -- if ctx.attr.target_javabase: -- inputs.extend(ctx.files.target_javabase) -- args.add(ctx.attr.target_javabase[java_common.JavaRuntimeInfo].java_home) - -+ inputs = depset([class_dir] + ctx.files.java_runtime_alias, transitive = [any_javabase.files]) - ctx.actions.run( -- executable = str(host_javabase.java_executable_exec_path), -+ executable = str(exec_javabase.java_executable_exec_path), - mnemonic = "JavaToolchainCompileBootClasspath", - inputs = inputs, - outputs = [bootclasspath], -@@ -267,7 +268,7 @@ def _bootclasspath_impl(ctx): - _bootclasspath = rule( - implementation = _bootclasspath_impl, - attrs = { -- "host_javabase": attr.label( -+ "java_runtime_alias": attr.label( - cfg = "exec", - providers = [java_common.JavaRuntimeInfo], - ), -@@ -276,10 +277,8 @@ _bootclasspath = rule( - cfg = "exec", - allow_single_file = True, - ), -- "target_javabase": attr.label( -- providers = [java_common.JavaRuntimeInfo], -- ), - }, -+ toolchains = [_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE], - ) - - def bootclasspath(name, **kwargs): -diff --git a/toolchains/local_java_repository.bzl b/toolchains/local_java_repository.bzl -index 3b8c386..1589d39 100644 ---- a/toolchains/local_java_repository.bzl -+++ b/toolchains/local_java_repository.bzl -@@ -101,6 +101,12 @@ def local_java_runtime(name, java_home, version, runtime_name = None, visibility - toolchain_type = Label("@bazel_tools//tools/jdk:runtime_toolchain_type"), - toolchain = runtime_name, - ) -+ native.toolchain( -+ name = "bootstrap_runtime_toolchain_definition", -+ target_settings = [":%s_settings_alias" % name], -+ toolchain_type = Label("@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type"), -+ toolchain = runtime_name, -+ ) - - if type(version) == type("") and version.isdigit() and int(version) > 8: - for version in range(8, int(version) + 1): -@@ -245,6 +251,12 @@ toolchain( - toolchain_type = "@bazel_tools//tools/jdk:runtime_toolchain_type", - toolchain = ":jdk", - ) -+toolchain( -+ name = "bootstrap_runtime_toolchain_definition", -+ target_settings = [":localjdk_setting"], -+ toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type", -+ toolchain = ":jdk", -+) - ''' - - _local_java_repository_rule = repository_rule( -diff --git a/toolchains/remote_java_repository.bzl b/toolchains/remote_java_repository.bzl -index 86916ec..65bbe48 100644 ---- a/toolchains/remote_java_repository.bzl -+++ b/toolchains/remote_java_repository.bzl -@@ -82,6 +82,16 @@ toolchain( - toolchain_type = "@bazel_tools//tools/jdk:runtime_toolchain_type", - toolchain = "{toolchain}", - ) -+toolchain( -+ name = "bootstrap_runtime_toolchain", -+ # These constraints are not required for correctness, but prevent fetches of remote JDK for -+ # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in -+ # the same configuration, this constraint will not result in toolchain resolution failures. -+ exec_compatible_with = {target_compatible_with}, -+ target_settings = [":version_or_prefix_version_setting"], -+ toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type", -+ toolchain = "{toolchain}", -+) - """.format( - prefix = prefix, - version = version, - -From 962ab9f9075bed19544b7cac0b53e512c62228e8 Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Wed, 5 Jul 2023 18:28:33 +0200 -Subject: [PATCH 2/4] Register toolchains in MODULE.bazel - ---- - MODULE.bazel | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/MODULE.bazel b/MODULE.bazel -index ac5cd19..d3729b9 100644 ---- a/MODULE.bazel -+++ b/MODULE.bazel -@@ -26,7 +26,10 @@ use_repo(toolchains, "remote_java_tools_darwin_arm64") - # Declare local jdk repo - use_repo(toolchains, "local_jdk") - --register_toolchains("@local_jdk//:runtime_toolchain_definition") -+register_toolchains( -+ "@local_jdk//:runtime_toolchain_definition", -+ "@local_jdk//:bootstrap_runtime_toolchain_definition", -+) - - # Declare all remote jdk toolchain config repos - JDKS = { -@@ -69,7 +72,7 @@ REMOTE_JDK_REPOS = [("remotejdk" + version + "_" + platform) for version in JDKS - repo + "_toolchain_config_repo", - ) for repo in REMOTE_JDK_REPOS] - --[register_toolchains("@" + name + "_toolchain_config_repo//:toolchain") for name in REMOTE_JDK_REPOS] -+[register_toolchains("@" + name + "_toolchain_config_repo//:all") for name in REMOTE_JDK_REPOS] - - # Dev dependencies - bazel_dep(name = "rules_pkg", version = "0.5.1", dev_dependency = True) - -From 58834b48f02deebddbc887f731a9199ce484a6e0 Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Mon, 31 Jul 2023 18:09:00 +0200 -Subject: [PATCH 3/4] Update Bazel to 7.0.0-pre.20230710.5 - ---- - .bazelversion | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 .bazelversion - -diff --git a/.bazelversion b/.bazelversion -new file mode 100644 -index 0000000..293346f ---- /dev/null -+++ b/.bazelversion -@@ -0,0 +1 @@ -+7.0.0-pre.20230710.5 - -From 6b04a310347861d00ecf6e439e200e559c6a1a90 Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Tue, 1 Aug 2023 10:45:39 +0200 -Subject: [PATCH 4/4] Add missing WORKSPACE `register_toolchains` calls - ---- - java/repositories.bzl | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/java/repositories.bzl b/java/repositories.bzl -index 7e5b939..a7cf3bd 100644 ---- a/java/repositories.bzl -+++ b/java/repositories.bzl -@@ -551,7 +551,13 @@ def rules_java_toolchains(name = "toolchains"): - - REMOTE_JDK_REPOS = [("remotejdk" + version + "_" + platform) for version in JDKS for platform in JDKS[version]] - -- native.register_toolchains("//toolchains:all") -- native.register_toolchains("@local_jdk//:runtime_toolchain_definition") -+ native.register_toolchains( -+ "//toolchains:all", -+ "@local_jdk//:runtime_toolchain_definition", -+ "@local_jdk//:bootstrap_runtime_toolchain_definition", -+ ) - for name in REMOTE_JDK_REPOS: -- native.register_toolchains("@" + name + "_toolchain_config_repo//:toolchain") -+ native.register_toolchains( -+ "@" + name + "_toolchain_config_repo//:toolchain", -+ "@" + name + "_toolchain_config_repo//:bootstrap_runtime_toolchain", -+ ) diff --git a/third_party/rules_jvm-fix-junit5-for-early-access-builds.patch b/third_party/rules_jvm-fix-junit5-for-early-access-builds.patch deleted file mode 100644 index caf9ab543..000000000 --- a/third_party/rules_jvm-fix-junit5-for-early-access-builds.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 297bdf9a7abb1980cacf911c7f2652884454dacf Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Mon, 14 Aug 2023 16:17:42 +0200 -Subject: [PATCH] Make JUnit5Runner usable with Early Access builds - -Fixes this crash: -``` -Exception in thread "main" java.lang.NumberFormatException: For input string: "21-ea" - at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) - at java.base/java.lang.Integer.parseInt(Integer.java:661) - at java.base/java.lang.Integer.parseInt(Integer.java:777) - at com.github.bazel_contrib.contrib_rules_jvm.junit5.JUnit5Runner.getSystemExitToggle(JUnit5Runner.java:57) - at com.github.bazel_contrib.contrib_rules_jvm.junit5.JUnit5Runner.main(JUnit5Runner.java:24) -``` ---- - .../bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java -index d331e590..b1e437b2 100644 ---- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java -+++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java -@@ -53,7 +53,8 @@ public static void main(String[] args) { - private static SystemExitToggle getSystemExitToggle() { - // In Java 8 and lower, the first part of the version is a 1. - // In Java 9 and higher, the first part of the version is the feature version. -- int featureVersion = Integer.parseInt(System.getProperty("java.version").split("\\.")[0]); -+ // Major versions of early Access builds have an "-ea" suffix. -+ int featureVersion = Integer.parseInt(System.getProperty("java.version").split("[.-]")[0]); - if (featureVersion == 1) { - featureVersion = 8; - } diff --git a/third_party/rules_jvm_external-javadoc-deps.patch b/third_party/rules_jvm_external-javadoc-deps.patch deleted file mode 100644 index b6c376077..000000000 --- a/third_party/rules_jvm_external-javadoc-deps.patch +++ /dev/null @@ -1,255 +0,0 @@ -From 119d0bf53b1a76436095986ffe11a0c97f1757db Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Mon, 11 Sep 2023 13:05:32 +0200 -Subject: [PATCH] javadoc: Allow `javadoc` targets to reference other `javadoc` - targets - -By setting the `doc_url` attribute on a `javadoc` target, other targets -can depend on it via `doc_deps` and have references resolved -automatically via appropriate `-linkoffline` arguments passed to -javadoc. ---- - private/rules/java_export.bzl | 21 ++++- - private/rules/javadoc.bzl | 77 +++++++++++++++++-- - .../javadoc/JavadocJarMaker.java | 15 ++++ - 3 files changed, 106 insertions(+), 7 deletions(-) - -diff --git a/private/rules/java_export.bzl b/private/rules/java_export.bzl -index 5c576f95..81138db1 100644 ---- a/private/rules/java_export.bzl -+++ b/private/rules/java_export.bzl -@@ -69,6 +69,10 @@ def java_export( - that workspace should be replaced by, or `None` if the exclusion shouldn't be replaced - with an extra dependency. - classifier_artifacts: A dict of classifier -> artifact of additional artifacts to publish to Maven. -+ doc_deps: Other `javadoc` targets that are referenced by the generated `javadoc` target -+ (if not using `tags = ["no-javadoc"]`) -+ doc_url: The URL at which the generated `javadoc` will be hosted (if not using -+ `tags = ["no-javadoc"]`). - visibility: The visibility of the target - kwargs: These are passed to [`java_library`](https://bazel.build/reference/be/java#java_library), - and so may contain any valid parameter for that rule. -@@ -78,6 +82,8 @@ def java_export( - lib_name = "%s-lib" % name - - javadocopts = kwargs.pop("javadocopts", []) -+ doc_deps = kwargs.pop("doc_deps", []) -+ doc_url = kwargs.pop("doc_url", "") - - # Construct the java_library we'll export from here. - native.java_library( -@@ -100,6 +106,8 @@ def java_export( - testonly, - javadocopts, - classifier_artifacts = classifier_artifacts, -+ doc_deps = doc_deps, -+ doc_url = doc_url, - ) - - def maven_export( -@@ -113,7 +121,10 @@ def maven_export( - tags = [], - testonly = False, - javadocopts = [], -- classifier_artifacts = {}): -+ classifier_artifacts = {}, -+ *, -+ doc_deps = [], -+ doc_url = ""): - """ - All arguments are the same as java_export with the addition of: - lib_name: Name of the library that has been built. -@@ -166,6 +177,10 @@ def maven_export( - that should not be included in the maven jar to a `Label` pointing to the dependency - that workspace should be replaced by, or `None` if the exclusion shouldn't be replaced - with an extra dependency. -+ doc_deps: Other `javadoc` targets that are referenced by the generated `javadoc` target -+ (if not using `tags = ["no-javadoc"]`) -+ doc_url: The URL at which the generated `javadoc` will be hosted (if not using -+ `tags = ["no-javadoc"]`). - visibility: The visibility of the target - kwargs: These are passed to [`java_library`](https://bazel.build/reference/be/java#java_library), - and so may contain any valid parameter for that rule. -@@ -176,6 +191,8 @@ def maven_export( - deploy_env = deploy_env if deploy_env else [] - excluded_workspaces = excluded_workspaces if excluded_workspaces else {} - javadocopts = javadocopts if javadocopts else [] -+ doc_url = doc_url if doc_url else "" -+ doc_deps = doc_deps if doc_deps else [] - tags = tags if tags else [] - classifier_artifacts = classifier_artifacts if classifier_artifacts else {} - -@@ -227,6 +244,8 @@ def maven_export( - ":%s-project" % name, - ] + deploy_env, - javadocopts = javadocopts, -+ doc_deps = doc_deps, -+ doc_url = doc_url, - excluded_workspaces = excluded_workspaces.keys(), - additional_dependencies = additional_dependencies, - visibility = visibility, -diff --git a/private/rules/javadoc.bzl b/private/rules/javadoc.bzl -index 3261248a..98ce3a08 100644 ---- a/private/rules/javadoc.bzl -+++ b/private/rules/javadoc.bzl -@@ -1,16 +1,42 @@ - load(":maven_project_jar.bzl", "DEFAULT_EXCLUDED_WORKSPACES") - --def generate_javadoc(ctx, javadoc, source_jars, classpath, javadocopts, output): -+_JavadocInfo = provider( -+ fields = { -+ "element_list": "The element-list or package-list file generated by javadoc", -+ "url": "The URL at which this documentation will be hosted", -+ }, -+) -+ -+def generate_javadoc( -+ ctx, -+ javadoc, -+ source_jars, -+ classpath, -+ javadocopts, -+ doc_deps, -+ output, -+ element_list): -+ inputs = [] -+ transitive_inputs = [] - args = ctx.actions.args() -- args.add_all(["--out", output]) -+ args.add("--out", output) -+ args.add("--element-list", element_list) - args.add_all(source_jars, before_each = "--in") -+ inputs.extend(source_jars) - args.add_all(classpath, before_each = "--cp") -+ transitive_inputs.append(classpath) -+ for dep in doc_deps: -+ dep_info = dep[_JavadocInfo] -+ args.add("-linkoffline") -+ args.add(dep_info.url) -+ args.add(dep_info.element_list.dirname) -+ inputs.append(dep_info.element_list) - args.add_all(javadocopts) - - ctx.actions.run( - executable = javadoc, -- outputs = [output], -- inputs = depset(source_jars, transitive = [classpath]), -+ outputs = [output, element_list], -+ inputs = depset(inputs, transitive = transitive_inputs), - arguments = [args], - ) - -@@ -21,6 +47,10 @@ def _javadoc_impl(ctx): - - jar_file = ctx.actions.declare_file("%s.jar" % ctx.attr.name) - -+ # This needs to be a in a separate directory as javadoc accepts the containing directory as -+ # an argument rather than the file itself. -+ element_list = ctx.actions.declare_file("%s-element-list-dir/element-list" % ctx.attr.name) -+ - # javadoc may need to inspect compile-time dependencies (neverlink) - # of the runtime classpath. - classpath = depset( -@@ -34,11 +64,29 @@ def _javadoc_impl(ctx): - # `None` https://github.com/bazelbuild/bazel/issues/10170). For this - # reason we allow people to set javadocopts via the rule attrs. - -- generate_javadoc(ctx, ctx.executable._javadoc, sources, classpath, ctx.attr.javadocopts, jar_file) -+ generate_javadoc( -+ ctx, -+ ctx.executable._javadoc, -+ sources, -+ classpath, -+ ctx.attr.javadocopts, -+ ctx.attr.doc_deps, -+ jar_file, -+ element_list, -+ ) - -- return [ -+ providers = [ - DefaultInfo(files = depset([jar_file])), - ] -+ if ctx.attr.doc_url: -+ providers.append( -+ _JavadocInfo( -+ element_list = element_list, -+ url = ctx.attr.doc_url, -+ ), -+ ) -+ -+ return providers - - javadoc = rule( - _javadoc_impl, -@@ -61,6 +109,23 @@ javadoc = rule( - options can be passed here. - """, - ), -+ "doc_deps": attr.label_list( -+ doc = """`javadoc` targets referenced by the current target. -+ -+ Use this to automatically add appropriate `-linkoffline` javadoc options to resolve -+ references to packages documented by the given javadoc targets that have `url` -+ specified. -+ """, -+ providers = [ -+ [_JavadocInfo], -+ ], -+ ), -+ "doc_url": attr.string( -+ doc = """The URL at which this documentation will be hosted. -+ -+ This information is only used by javadoc targets depending on this target. -+ """, -+ ), - "excluded_workspaces": attr.string_list( - doc = "A list of bazel workspace names to exclude from the generated jar", - allow_empty = True, -diff --git a/private/tools/java/com/github/bazelbuild/rules_jvm_external/javadoc/JavadocJarMaker.java b/private/tools/java/com/github/bazelbuild/rules_jvm_external/javadoc/JavadocJarMaker.java -index 6e8b57e6..550e075a 100644 ---- a/private/tools/java/com/github/bazelbuild/rules_jvm_external/javadoc/JavadocJarMaker.java -+++ b/private/tools/java/com/github/bazelbuild/rules_jvm_external/javadoc/JavadocJarMaker.java -@@ -22,6 +22,7 @@ - import com.github.bazelbuild.rules_jvm_external.ByteStreams; - import com.github.bazelbuild.rules_jvm_external.zip.StableZipEntry; - import java.io.File; -+import java.io.FileNotFoundException; - import java.io.IOException; - import java.io.InputStream; - import java.io.OutputStream; -@@ -57,6 +58,7 @@ public class JavadocJarMaker { - public static void main(String[] args) throws IOException { - Set sourceJars = new HashSet<>(); - Path out = null; -+ Path elementList = null; - Set classpath = new HashSet<>(); - List options = new ArrayList<>(); - -@@ -80,6 +82,11 @@ public static void main(String[] args) throws IOException { - out = Paths.get(next); - break; - -+ case "--element-list": -+ next = args[++i]; -+ elementList = Paths.get(next); -+ break; -+ - default: - options.add(flag); - break; -@@ -167,6 +174,14 @@ public static void main(String[] args) throws IOException { - return; - } - -+ Path generatedElementList = outputTo.resolve("element-list"); -+ try { -+ Files.copy(generatedElementList, elementList); -+ } catch (FileNotFoundException e) { -+ // Do not fail the action if the generated element-list couldn't be found. -+ Files.createFile(generatedElementList); -+ } -+ - try (OutputStream os = Files.newOutputStream(out); - ZipOutputStream zos = new ZipOutputStream(os); - Stream walk = Files.walk(outputTo)) { diff --git a/third_party/rules_kotlin-remove-java-info-transitive-deps.patch b/third_party/rules_kotlin-remove-java-info-transitive-deps.patch deleted file mode 100644 index 1f79b78d1..000000000 --- a/third_party/rules_kotlin-remove-java-info-transitive-deps.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 5633d284a6c77882487ef58885dbcbfd24c07f9c Mon Sep 17 00:00:00 2001 -From: hvadehra -Date: Fri, 11 Aug 2023 09:10:16 +0200 -Subject: [PATCH] Migrate usages deprecated `JavaInfo` fields - -transitive_deps was an alias for transitive_compile_time_jars transitive_runtime_deps was an alias for transitive_runtime_jars - -The fields were deprecated in 2021, and are dropped in Bazel@HEAD - -Fixes bazelbuild#1003 ---- - kotlin/internal/jvm/compile.bzl | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kotlin/internal/jvm/compile.bzl b/kotlin/internal/jvm/compile.bzl -index 80cbf7a8..327a0bdc 100644 ---- a/kotlin/internal/jvm/compile.bzl -+++ b/kotlin/internal/jvm/compile.bzl -@@ -261,7 +261,7 @@ def _run_merge_jdeps_action(ctx, toolchains, jdeps, outputs, deps): - ) - - # For sandboxing to work, and for this action to be deterministic, the compile jars need to be passed as inputs -- inputs = depset(jdeps, transitive = [depset([], transitive = [dep.transitive_deps for dep in deps])]) -+ inputs = depset(jdeps, transitive = [depset([], transitive = [dep.transitive_compile_time_jars for dep in deps])]) - - ctx.actions.run( - mnemonic = mnemonic, diff --git a/third_party/rules_kotlin-remove-java-runtime-dep.patch b/third_party/rules_kotlin-remove-java-runtime-dep.patch deleted file mode 100644 index a82585926..000000000 --- a/third_party/rules_kotlin-remove-java-runtime-dep.patch +++ /dev/null @@ -1,65 +0,0 @@ -From cec904da75a345d4bf021855ad506657a0a4b23d Mon Sep 17 00:00:00 2001 -From: Fabian Meumertzheim -Date: Tue, 1 Aug 2023 13:48:57 +0200 -Subject: [PATCH] Remove unnecessary Java runtime dependencies - -`kt_jvm_library` no longer depends on a Java runtime for the target -platform, which ensures that cross-platform builds targeting platforms -without standalone Java runtimes (e.g. Android) can succeed without -hacks (currently, Bazel's local_jdk is marked as compatible with any -target platform, but that will change in the future). ---- - kotlin/internal/jvm/jvm.bzl | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/kotlin/internal/jvm/jvm.bzl b/kotlin/internal/jvm/jvm.bzl -index 61fcb0ecc..822dd1597 100644 ---- a/kotlin/internal/jvm/jvm.bzl -+++ b/kotlin/internal/jvm/jvm.bzl -@@ -149,6 +149,9 @@ _implicit_deps = { - default = Label("@bazel_tools//tools/jdk:current_java_runtime"), - cfg = "exec", - ), -+} -+ -+_runnable_implicit_deps = { - "_java_runtime": attr.label( - default = Label("@bazel_tools//tools/jdk:current_java_runtime"), - ), -@@ -269,7 +272,7 @@ this is not transitive""", - ), - }) - --_runnable_common_attr = utils.add_dicts(_common_attr, { -+_runnable_common_attr = utils.add_dicts(_common_attr, _runnable_implicit_deps, { - "jvm_flags": attr.string_list( - doc = """A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet - support make variable substitution.""", -@@ -287,6 +290,9 @@ _common_outputs = dict( - _common_toolchains = [ - _TOOLCHAIN_TYPE, - _JAVA_TOOLCHAIN_TYPE, -+] -+ -+_runnable_common_toolchains = [ - _JAVA_RUNTIME_TOOLCHAIN_TYPE, - ] - -@@ -318,7 +324,7 @@ It is appropriate for building workspace utilities. `java_binary` should be pref - }.items()), - executable = True, - outputs = _common_outputs, -- toolchains = _common_toolchains, -+ toolchains = _common_toolchains + _runnable_common_toolchains, - fragments = ["java"], # Required fragments of the target configuration - host_fragments = ["java"], # Required fragments of the host configuration - implementation = _kt_jvm_binary_impl, -@@ -353,7 +359,7 @@ Setup a simple kotlin_test. - executable = True, - outputs = _common_outputs, - test = True, -- toolchains = _common_toolchains, -+ toolchains = _common_toolchains + _runnable_common_toolchains, - implementation = _kt_jvm_junit_test_impl, - fragments = ["java"], # Required fragments of the target configuration - host_fragments = ["java"], # Required fragments of the host configuration