Bazel plugin in IDEA doesn't work for me.
And even when it worked, it didn't allow many Java features, e.g. profiling.
I created a much simpler setup.
Just wanted to share it with other Selenium maintainers.
- Created script
scripts/prepare_idea_java_project.sh that copies all Java dependencies to a folder:
- Run this script
- Open the project in IDEA as a simple Java project
- Bingo! All Java features work: running, debugging, profiling; running multiple selected tests etc.
Script scripts/prepare_idea_java_project.sh
(written with the help of ChatGPT, of cause)
#!/usr/bin/env bash
# Prepare an IntelliJ IDEA java project by copying Bazel-built dependency jars
# into ./java-libs so the IDE can resolve them.
#
# Prerequisites:
# - Run anywhere inside the Selenium repo (script cd's to the repo root).
set -euo pipefail
shopt -s nullglob
cd "$(git rev-parse --show-toplevel)"
bazel build //java/... --pin_browsers=true
LIB="$PWD/java-libs"
rm -rf "$LIB"
mkdir -p "$LIB"
EXECROOT=$(bazel info execution_root)
# To exclude sources:
# and not f.path.endswith("-sources.jar")
# JUnit jars are excluded because IntelliJ bundles its own copy.
bazel cquery \
'deps(kind("java_test", //java/...))' \
--output=starlark \
--starlark:expr='"\n".join([
f.path
for f in target.files.to_list()
if f.path.endswith(".jar")
and (f.path.startswith("external/") or "/genfiles/" in f.path or ("/devtools/v" in f.path and f.path.endswith("-project.jar")))
and (not "junit-jupiter-engine" in f.path)
and (not "junit-platform-engine" in f.path)
and (not "junit-platform-launcher" in f.path)
and (not "junit-platform-reporting" in f.path)
])' \
| sort -u \
| while IFS= read -r rel; do
[[ -z "$rel" ]] && continue
abs="$EXECROOT/$rel"
dest="$LIB/$(basename "$abs")"
if [[ -e "$dest" ]]; then
echo "warn: overwriting $dest (basename collision)" >&2
fi
cp "$abs" "$dest"
chmod u+w "$dest"
done
# Bazel's own runfiles library used by Selenium code
runfiles=(.ijwb/.blaze/libraries/librunfiles-hjar*.jar)
if (( ${#runfiles[@]} == 0 )); then
echo "warn: no librunfiles-hjar*.jar found — sync the IntelliJ Bazel plugin first" >&2
else
cp "${runfiles[@]}" "$LIB/"
fi
echo "✔ Dependency jars only: $(ls -1 "$LIB" | wc -l)"
IDEA project setup

Bazel plugin in IDEA doesn't work for me.
And even when it worked, it didn't allow many Java features, e.g. profiling.
I created a much simpler setup.
Just wanted to share it with other Selenium maintainers.
scripts/prepare_idea_java_project.shthat copies all Java dependencies to a folder:Script scripts/prepare_idea_java_project.sh
(written with the help of ChatGPT, of cause)
IDEA project setup