From 2c3a16bb542b1449bb84a39a05dc07cd96dce2c0 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 5 Nov 2018 14:42:40 +0000 Subject: [PATCH] Initial spike on bazel compilation Install the latest version of bazel, and try building `bazel build java/client/src/org/openqa/selenium/remote` If everything goes according to plan, this will have built the remote java bindings. Woot. The design principles for the BUILD files are fairly simple: * Keep It Stupidly Simple (aim for one target per file) * Only use public visibility for rules that will generate a publicly downloadable artifect (eg. a maven jar, a ruby gem, etc) * Minimal visibility for everything else * Each rule should only be reachable from one publicly visible rule (allowing us to generate deployment descriptors when we get there) Problems to address before we can consider switching to bazel for all builds: * The publishing story is a mess. Notably, Buck made it easy to push to maven central. Bazel's a mess for this. * Generating java 9 module information. This is probably just a case of copying what we did for Buck. * How to properly integrate into the rest of the build, in particular for those languages we didn't properly cover off with Buck (though that's not a blocker --- feature parity with what we have is) --- .bazelrc | 11 ++++ .gitignore | 8 +++ WORKSPACE | 0 java/client/src/org/openqa/selenium/BUILD | 17 ++++++ java/client/src/org/openqa/selenium/io/BUILD | 11 ++++ .../client/src/org/openqa/selenium/json/BUILD | 12 +++++ java/client/src/org/openqa/selenium/net/BUILD | 11 ++++ java/client/src/org/openqa/selenium/os/BUILD | 13 +++++ .../src/org/openqa/selenium/remote/BUILD | 52 +++++++++++++++++++ third_party/java/bytebuddy/BUILD | 13 +++++ third_party/java/commons/BUILD | 13 +++++ third_party/java/guava/BUILD | 13 +++++ third_party/java/okhttp3/BUILD | 16 ++++++ third_party/java/okio/BUILD | 13 +++++ 14 files changed, 203 insertions(+) create mode 100644 .bazelrc create mode 100644 WORKSPACE create mode 100644 java/client/src/org/openqa/selenium/BUILD create mode 100644 java/client/src/org/openqa/selenium/io/BUILD create mode 100644 java/client/src/org/openqa/selenium/json/BUILD create mode 100644 java/client/src/org/openqa/selenium/net/BUILD create mode 100644 java/client/src/org/openqa/selenium/os/BUILD create mode 100644 java/client/src/org/openqa/selenium/remote/BUILD create mode 100644 third_party/java/bytebuddy/BUILD create mode 100644 third_party/java/commons/BUILD create mode 100644 third_party/java/guava/BUILD create mode 100644 third_party/java/okhttp3/BUILD create mode 100644 third_party/java/okio/BUILD diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000000000..67ae4d95a2ba0 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,11 @@ + +# We target java 8 by default +build --javacopt "-source 8" +build --javacopt "-target 8" + +# Require java dependencies to be used and first-order +build --strict_java_deps strict + +# Make sure we get something helpful when tests fail +test --verbose_failures +test --test_output=errors \ No newline at end of file diff --git a/.gitignore b/.gitignore index e14defe791acd..1b1a0a0494a87 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,11 @@ third_party/py/googlestorage/client_secrets.json venv venv3 py/.idea + +# Bazel stuff +bazel-bin +bazel-genfiles +bazel-out +bazel-selenium +bazel-testlogs + diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/java/client/src/org/openqa/selenium/BUILD b/java/client/src/org/openqa/selenium/BUILD new file mode 100644 index 0000000000000..1adca9698cdea --- /dev/null +++ b/java/client/src/org/openqa/selenium/BUILD @@ -0,0 +1,17 @@ +java_library( + name = "selenium", + srcs = glob([ + "*.java", + "html5/*.java", + "internal/*.java", + "interactions/**/*.java", + "logging/**/*.java", + "mobile/*.java", + ]), + deps = [ + # Deliberately left empty of third party deps + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/java/client/src/org/openqa/selenium/io/BUILD b/java/client/src/org/openqa/selenium/io/BUILD new file mode 100644 index 0000000000000..7b3ae8936f3e8 --- /dev/null +++ b/java/client/src/org/openqa/selenium/io/BUILD @@ -0,0 +1,11 @@ +java_library( + name = "io", + srcs = glob(["*.java"]), + deps = [ + "//java/client/src/org/openqa/selenium", + ], + visibility = [ + "//java/client/src/org/openqa/selenium/os:__pkg__", + "//java/client/src/org/openqa/selenium/remote:__pkg__", + ], +) diff --git a/java/client/src/org/openqa/selenium/json/BUILD b/java/client/src/org/openqa/selenium/json/BUILD new file mode 100644 index 0000000000000..fe389914ab3d1 --- /dev/null +++ b/java/client/src/org/openqa/selenium/json/BUILD @@ -0,0 +1,12 @@ +java_library( + name = "json", + srcs = glob(["*.java"]), + deps = [ + "//java/client/src/org/openqa/selenium", + "//java/client/src/org/openqa/selenium/remote:types", + "//third_party/java/guava:guava", + ], + visibility = [ + "//java/client/src/org/openqa/selenium/remote:__pkg__", + ], +) diff --git a/java/client/src/org/openqa/selenium/net/BUILD b/java/client/src/org/openqa/selenium/net/BUILD new file mode 100644 index 0000000000000..47638b34ef99f --- /dev/null +++ b/java/client/src/org/openqa/selenium/net/BUILD @@ -0,0 +1,11 @@ +java_library( + name = "net", + srcs = glob(["*.java"]), + deps = [ + "//java/client/src/org/openqa/selenium", + "//third_party/java/guava", + ], + visibility = [ + "//java/client/src/org/openqa/selenium/remote:__pkg__", + ], +) diff --git a/java/client/src/org/openqa/selenium/os/BUILD b/java/client/src/org/openqa/selenium/os/BUILD new file mode 100644 index 0000000000000..79370aba5927c --- /dev/null +++ b/java/client/src/org/openqa/selenium/os/BUILD @@ -0,0 +1,13 @@ +java_library( + name = "os", + srcs = glob(["*.java"]), + deps = [ + "//java/client/src/org/openqa/selenium", + "//java/client/src/org/openqa/selenium/io", + "//third_party/java/commons:commons-exec", + "//third_party/java/guava", + ], + visibility = [ + "//java/client/src/org/openqa/selenium/remote:__pkg__", + ], +) diff --git a/java/client/src/org/openqa/selenium/remote/BUILD b/java/client/src/org/openqa/selenium/remote/BUILD new file mode 100644 index 0000000000000..647f60e688bbc --- /dev/null +++ b/java/client/src/org/openqa/selenium/remote/BUILD @@ -0,0 +1,52 @@ +TYPE_SOURCES = [ + "Command.java", + "ErrorCodes.java", + "Response.java", + "ScreenshotException.java", + "SessionId.java", +] + +java_library( + name = "remote", + srcs = glob([ + "*.java", + "html5/*.java", + "http/*.java", + "internal/*.java", + "mobile/*.java", + "service/*.java", + "session/*.java", + ], exclude = TYPE_SOURCES), + exports = [ + "//java/client/src/org/openqa/selenium", + "//java/client/src/org/openqa/selenium/json", + "//java/client/src/org/openqa/selenium/io", + "//java/client/src/org/openqa/selenium/net", + "//java/client/src/org/openqa/selenium/os", + ], + deps = [ + ":types", + "//java/client/src/org/openqa/selenium", + "//java/client/src/org/openqa/selenium/json", + "//java/client/src/org/openqa/selenium/io", + "//java/client/src/org/openqa/selenium/net", + "//java/client/src/org/openqa/selenium/os", + "//third_party/java/bytebuddy:byte-buddy", + "//third_party/java/guava", + "//third_party/java/okhttp3:okhttp", + ], + visibility = [ + ], +) + +java_library( + name = "types", + srcs = TYPE_SOURCES, + deps = [ + "//java/client/src/org/openqa/selenium", + "//third_party/java/guava", + ], + visibility = [ + "//java/client/src/org/openqa/selenium/json:__pkg__", + ], +) diff --git a/third_party/java/bytebuddy/BUILD b/third_party/java/bytebuddy/BUILD new file mode 100644 index 0000000000000..5c59037398161 --- /dev/null +++ b/third_party/java/bytebuddy/BUILD @@ -0,0 +1,13 @@ +java_import( + name = 'byte-buddy', + jars = [ + 'byte-buddy-1.8.15.jar', + ], + licenses = [ + "notice", # Apache 2 + ], + srcjar = 'byte-buddy-1.8.15-sources.jar', + visibility = [ + '//java/client/src/org/openqa/selenium/remote:__pkg__', + ], +) diff --git a/third_party/java/commons/BUILD b/third_party/java/commons/BUILD new file mode 100644 index 0000000000000..ae9078996a128 --- /dev/null +++ b/third_party/java/commons/BUILD @@ -0,0 +1,13 @@ +java_import( + name = 'commons-exec', + licenses = [ + "notice", # Apache 2 + ], + jars = [ + 'commons-exec-1.3.jar', + ], + srcjar = 'commons-exec-1.3-sources.jar', + visibility = [ + '//java/client/src/org/openqa/selenium/os:__pkg__', + ], +) diff --git a/third_party/java/guava/BUILD b/third_party/java/guava/BUILD new file mode 100644 index 0000000000000..a1800a8ffe5f0 --- /dev/null +++ b/third_party/java/guava/BUILD @@ -0,0 +1,13 @@ + +java_import( + name = "guava", + licenses = [ + "notice", # Apache 2 + ], + jars = [ + "guava-25.0-jre.jar", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/third_party/java/okhttp3/BUILD b/third_party/java/okhttp3/BUILD new file mode 100644 index 0000000000000..878213c37fc0e --- /dev/null +++ b/third_party/java/okhttp3/BUILD @@ -0,0 +1,16 @@ +java_import( + name = 'okhttp', + licenses = [ + "notice" # Apache 2 + ], + jars = [ + 'okhttp-3.11.0.jar', + ], + srcjar = 'okhttp-3.11.0-sources.jar', + deps = [ + '//third_party/java/okio:okio' + ], + visibility = [ + '//java/client/src/org/openqa/selenium/remote:__pkg__', + ], +) diff --git a/third_party/java/okio/BUILD b/third_party/java/okio/BUILD new file mode 100644 index 0000000000000..862464f59f89a --- /dev/null +++ b/third_party/java/okio/BUILD @@ -0,0 +1,13 @@ +java_import( + name = 'okio', + licenses = [ + "notice", # Apache 2 + ], + jars = [ + 'okio-1.14.0.jar', + ], + srcjar = 'okio-1.14.0-sources.jar', + visibility = [ + '//third_party/java/okhttp3:__pkg__' + ], +)