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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion java/src/org/openqa/selenium/devtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<LATEST>` 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
Expand Down
66 changes: 66 additions & 0 deletions java/src/org/openqa/selenium/devtools/latest/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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,
],
)

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",
)
6 changes: 5 additions & 1 deletion java/src/org/openqa/selenium/devtools/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
1 change: 1 addition & 0 deletions rake_tasks/java.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading