Skip to content

Commit

Permalink
Initial spike on bazel compilation
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
shs96c committed Nov 5, 2018
1 parent 2bab50b commit 2c3a16b
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .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
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -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

Empty file added WORKSPACE
Empty file.
17 changes: 17 additions & 0 deletions 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",
],
)
11 changes: 11 additions & 0 deletions 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__",
],
)
12 changes: 12 additions & 0 deletions 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__",
],
)
11 changes: 11 additions & 0 deletions 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__",
],
)
13 changes: 13 additions & 0 deletions 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__",
],
)
52 changes: 52 additions & 0 deletions 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__",
],
)
13 changes: 13 additions & 0 deletions 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__',
],
)
13 changes: 13 additions & 0 deletions 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__',
],
)
13 changes: 13 additions & 0 deletions 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",
],
)
16 changes: 16 additions & 0 deletions 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__',
],
)
13 changes: 13 additions & 0 deletions 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__'
],
)

0 comments on commit 2c3a16b

Please sign in to comment.