From 47bbc0ea07b9cb0ecadf62425083f7dc5ec4e1cc Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Sat, 23 May 2026 18:40:04 -0500 Subject: [PATCH 1/2] [java] publish selenium-devtools-latest alias artifact --- .../org/openqa/selenium/devtools/README.md | 16 ++++- .../selenium/devtools/latest/BUILD.bazel | 70 +++++++++++++++++++ .../org/openqa/selenium/devtools/versions.bzl | 6 +- rake_tasks/java.rake | 1 + 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 java/src/org/openqa/selenium/devtools/latest/BUILD.bazel diff --git a/java/src/org/openqa/selenium/devtools/README.md b/java/src/org/openqa/selenium/devtools/README.md index c7c29ee961915..ad598862548ad 100644 --- a/java/src/org/openqa/selenium/devtools/README.md +++ b/java/src/org/openqa/selenium/devtools/README.md @@ -7,13 +7,27 @@ They are typically downloaded from the [devtools source](https://github.com/ChromeDevTools/devtools-protocol/tree/master/json) * Edit `//java/src/org/openqa/selenium/devtools:versions.bzl` to include the new version number (and - possibly delete the old one, we tend to support only the last 3 versions) + possibly delete the old one, we tend to support only the last 3 versions). `LATEST_CDP_VERSION` is + computed automatically from `CDP_VERSIONS` and does not need to be edited. * Copy the most recent `//java/src/org/openqa/selenium/devtools/vXX` to `//java/src/org/openqa/selenium/devtools/vXX+1`. * Do a search and replace in that directory, converting `XX` to `XX+1` * Add `//java/src/org/openqa/selenium/devtools/vXX:vXX.publish` version to the [Rakefile][]. * Compile the code and fix the places where signatures have changed. +The `selenium-devtools-latest` artifact is a stable alias that republishes the protocol classes of +`LATEST_CDP_VERSION` under the `org.openqa.selenium.devtools.latest` package. Users who don't want +to update their imports on every Chrome bump can write: + +```java +import org.openqa.selenium.devtools.latest.page.Page; +``` + +The alias artifact contains only the generated protocol types; the runtime `CdpInfo` registration +is provided by the versioned `selenium-devtools-v` artifact, which is pulled in as a +transitive Maven dependency. The alias is rebuilt automatically when a new CDP version is added — no +extra steps are required when bumping `CDP_VERSIONS`. + [README]: https://github.com/SeleniumHQ/selenium/tree/trunk/common/devtools [versions]: https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/devtools/versions.bzl diff --git a/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel b/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel new file mode 100644 index 0000000000000..f70a3f3418d32 --- /dev/null +++ b/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel @@ -0,0 +1,70 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("//common:defs.bzl", "copy_file") +load("//java:defs.bzl", "java_export", "java_library") +load("//java:version.bzl", "SE_VERSION") +load("//java/src/org/openqa/selenium/devtools:versions.bzl", "LATEST_CDP_VERSION") + +java_export( + name = "latest", + srcs = [], + maven_coordinates = "org.seleniumhq.selenium:selenium-devtools-latest:%s" % SE_VERSION, + opens_to = [ + "org.seleniumhq.selenium.json", + ], + pom_template = "//java/src/org/openqa/selenium:template-pom", + tags = [ + "release-artifact", + ], + visibility = [ + "//visibility:public", + ], + exports = [ + ":cdp", + "//java/src/org/openqa/selenium/devtools/%s" % LATEST_CDP_VERSION, + ], + runtime_deps = [ + ":cdp", + "//java/src/org/openqa/selenium/devtools/%s" % LATEST_CDP_VERSION, + ], +) + +java_library( + name = "cdp", + srcs = [ + ":create-cdp-srcs", + ], + tags = [ + "no-lint", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote", + artifact("org.jspecify:jspecify"), + ], +) + +genrule( + name = "create-cdp-srcs", + srcs = [ + ":browser_protocol", + ":js_protocol", + ], + outs = ["cdp.srcjar"], + cmd = "$(location //java/src/org/openqa/selenium/devtools:cdp-client-generator) $(location :browser_protocol) $(location :js_protocol) latest $@", + tools = [ + "//java/src/org/openqa/selenium/devtools:cdp-client-generator", + ], +) + +copy_file( + name = "browser_protocol", + src = "//common/devtools/chromium/%s:browser_protocol" % LATEST_CDP_VERSION, + out = "browser_protocol.json", +) + +copy_file( + name = "js_protocol", + src = "//common/devtools/chromium/%s:js_protocol" % LATEST_CDP_VERSION, + out = "js_protocol.json", +) diff --git a/java/src/org/openqa/selenium/devtools/versions.bzl b/java/src/org/openqa/selenium/devtools/versions.bzl index c546b9b603489..2ed8b94a13be2 100644 --- a/java/src/org/openqa/selenium/devtools/versions.bzl +++ b/java/src/org/openqa/selenium/devtools/versions.bzl @@ -4,4 +4,8 @@ CDP_VERSIONS = [ "v148", ] -CDP_DEPS = ["//java/src/org/openqa/selenium/devtools/%s" % v for v in CDP_VERSIONS] +LATEST_CDP_VERSION = "v" + str(max([int(v[1:]) for v in CDP_VERSIONS])) + +CDP_DEPS = ["//java/src/org/openqa/selenium/devtools/%s" % v for v in CDP_VERSIONS] + [ + "//java/src/org/openqa/selenium/devtools/latest", +] diff --git a/rake_tasks/java.rake b/rake_tasks/java.rake index 294a1d8881e66..f4c3884caea39 100644 --- a/rake_tasks/java.rake +++ b/rake_tasks/java.rake @@ -10,6 +10,7 @@ JAVA_RELEASE_TARGETS = %w[ //java/src/org/openqa/selenium/devtools/v146:v146.publish //java/src/org/openqa/selenium/devtools/v147:v147.publish //java/src/org/openqa/selenium/devtools/v148:v148.publish + //java/src/org/openqa/selenium/devtools/latest:latest.publish //java/src/org/openqa/selenium/edge:edge.publish //java/src/org/openqa/selenium/firefox:firefox.publish //java/src/org/openqa/selenium/grid/node/kubernetes:kubernetes.publish From 9609c4b746646e3094b4498d28187ea5d76bd414 Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Sun, 24 May 2026 12:58:08 -0500 Subject: [PATCH 2/2] remove redundant runtime_deps --- java/src/org/openqa/selenium/devtools/latest/BUILD.bazel | 4 ---- 1 file changed, 4 deletions(-) diff --git a/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel b/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel index f70a3f3418d32..55823c5199b54 100644 --- a/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel +++ b/java/src/org/openqa/selenium/devtools/latest/BUILD.bazel @@ -22,10 +22,6 @@ java_export( ":cdp", "//java/src/org/openqa/selenium/devtools/%s" % LATEST_CDP_VERSION, ], - runtime_deps = [ - ":cdp", - "//java/src/org/openqa/selenium/devtools/%s" % LATEST_CDP_VERSION, - ], ) java_library(