Updates for Bazel 0.23 compatibility (#3209)

* initial set of fixes

* add empty build file. update WORKSPACE

* update py protobuf to 3.6.1

* fix pex and javadoc rules

* update travis bazel version

* update --jobs to 1

* revert whitespace changes
diff --git a/.bazelrc b/.bazelrc
new file mode 100644
index 0000000..416f122
--- /dev/null
+++ b/.bazelrc
@@ -0,0 +1 @@
+import %workspace%/tools/bazel.rc
diff --git a/.travis.yml b/.travis.yml
index b8c0c4e..464e5b4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,9 +30,9 @@
 
 before_install:
   # download and install bazel
-  - wget -q 'https://github.com/bazelbuild/bazel/releases/download/0.14.1/bazel-0.14.1-installer-linux-x86_64.sh'
-  - chmod +x bazel-0.14.1-installer-linux-x86_64.sh
-  - ./bazel-0.14.1-installer-linux-x86_64.sh --user
+  - wget -q 'https://github.com/bazelbuild/bazel/releases/download/0.23.1/bazel-0.23.1-installer-linux-x86_64.sh'
+  - chmod +x bazel-0.23.1-installer-linux-x86_64.sh
+  - ./bazel-0.23.1-installer-linux-x86_64.sh --user
 
 before_script:
   # install python module for wheel files
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/BUILD
diff --git a/WORKSPACE b/WORKSPACE
index ca5ee6c..6e4f4b0 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -17,6 +17,8 @@
 
 workspace(name = "org_apache_heron")
 
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar")
+
 # versions shared across artifacts that should be upgraded together
 aws_version = "1.11.58"
 curator_version = "2.9.0"
@@ -784,38 +786,44 @@
 WHEEL_SRC = "https://pypi.python.org/packages/c9/1d/bd19e691fd4cfe908c76c429fe6e4436c9e83583c4414b54f6c85471954a/wheel-0.29.0.tar.gz"
 
 http_file(
-    name = 'pytest_whl',
-    url = PYTEST_WHEEL,
+    name = "pytest_whl",
+    downloaded_file_path = "pytest-3.1.3-py2.py3-none-any.whl",
+    urls = [PYTEST_WHEEL],
 )
 
 http_file(
-    name = 'py_whl',
-    url = PY_WHEEL,
+    name = "py_whl",
+    downloaded_file_path = "py-1.4.34-py2.py3-none-any.whl",
+    urls = [PY_WHEEL],
 )
 
 http_file(
     name = "wheel_src",
-    url = WHEEL_SRC,
+    downloaded_file_path = "wheel-0.29.0.tar.gz",
+    urls = [WHEEL_SRC],
 )
 
 http_file(
     name = "pex_src",
-    url = PEX_SRC,
+    downloaded_file_path = "pex-1.2.15.tar.gz",
+    urls = [PEX_SRC],
 )
 
 http_file(
     name = "requests_src",
-    url = REQUESTS_SRC,
+    downloaded_file_path = "requests-2.12.3.tar.gz",
+    urls = [REQUESTS_SRC],
 )
 
 http_file(
     name = "setuptools_src",
-    url = SETUPTOOLS_SRC,
+    downloaded_file_path = "setuptools-31.0.0.tar.gz",
+    urls = [SETUPTOOLS_SRC],
 )
 
-new_http_archive(
+http_archive(
     name = "virtualenv",
-    url = VIRTUALENV_SRC,
+    urls = [VIRTUALENV_SRC],
     strip_prefix = VIRTUALENV_PREFIX,
     build_file_content = "\n".join([
         "py_binary(",
@@ -832,9 +840,9 @@
 # protobuf dependencies for C++ and Java
 http_archive(
     name = "com_google_protobuf",
-    urls = ["https://github.com/google/protobuf/archive/v3.4.1.tar.gz"],
-    strip_prefix = "protobuf-3.4.1",
-    sha256 = "8e0236242106e680b4f9f576cc44b8cd711e948b20a9fc07769b0a20ceab9cc4",
+    urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.tar.gz"],
+    strip_prefix = "protobuf-3.6.1.3",
+    sha256 = "73fdad358857e120fd0fa19e071a96e15c0f23bb25f85d3f7009abfd4f264a2a",
 )
 # end protobuf dependencies for C++ and Java
 
@@ -846,91 +854,93 @@
     sha256 = "ae27cdbcd6a2f935baa78e4f21f675649271634c092b1be01469440495609d0e",
 )
 
-new_http_archive(
+http_archive(
     name = "org_libevent_libevent",
     urls = ["https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz"],
     strip_prefix = "libevent-2.1.8-stable",
-    build_file = "third_party/libevent/libevent.BUILD",
+    build_file = "@//:third_party/libevent/libevent.BUILD",
     sha256 = "965cc5a8bb46ce4199a47e9b2c9e1cae3b137e8356ffdad6d94d3b9069b71dc2",
 )
 
-new_http_archive(
+http_archive(
     name = "org_nongnu_libunwind",
     urls = ["http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.1.tar.gz"],
     strip_prefix = "libunwind-1.1",
-    build_file = "third_party/libunwind/libunwind.BUILD",
+    build_file = "@//:third_party/libunwind/libunwind.BUILD",
     sha256 = "9dfe0fcae2a866de9d3942c66995e4b460230446887dbdab302d41a8aee8d09a",
 )
 
-new_http_archive(
+http_archive(
     name = "org_apache_zookeeper",
     urls = ["http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz"],
     strip_prefix = "zookeeper-3.4.10",
-    build_file = "third_party/zookeeper/zookeeper.BUILD",
+    build_file = "@//:third_party/zookeeper/zookeeper.BUILD",
     sha256 = "7f7f5414e044ac11fee2a1e0bc225469f51fb0cdf821e67df762a43098223f27",
 )
 
-new_http_archive(
+http_archive(
     name = "com_github_gperftools_gperftools",
     urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.4/gperftools-2.4.tar.gz"],
     strip_prefix = "gperftools-2.4",
-    build_file = "third_party/gperftools/gperftools.BUILD",
+    build_file = "@//:third_party/gperftools/gperftools.BUILD",
     sha256 = "982a37226eb42f40714e26b8076815d5ea677a422fb52ff8bfca3704d9c30a2d",
 )
 
-new_http_archive(
+http_archive(
     name = "com_github_google_glog",
     urls = ["https://github.com/google/glog/archive/v0.3.5.tar.gz"],
     strip_prefix = "glog-0.3.5",
-    build_file = "third_party/glog/glog.BUILD",
+    build_file = "@//:third_party/glog/glog.BUILD",
     sha256 = "7580e408a2c0b5a89ca214739978ce6ff480b5e7d8d7698a2aa92fadc484d1e0",
 )
 
-new_http_archive(
+http_archive(
     name = "com_google_googletest",
     urls = ["https://github.com/google/googletest/archive/release-1.8.0.tar.gz"],
     strip_prefix = "googletest-release-1.8.0",
-    build_file = "third_party/gtest/gtest.BUILD",
+    build_file = "@//:third_party/gtest/gtest.BUILD",
     sha256 = "58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8",
 )
 
-new_http_archive(
+http_archive(
     name = "com_github_cereal",
     urls = ["https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz"],
     strip_prefix = "cereal-1.2.2",
-    build_file = "third_party/cereal/cereal.BUILD",
+    build_file = "@//:third_party/cereal/cereal.BUILD",
     sha256 = "1921f26d2e1daf9132da3c432e2fd02093ecaedf846e65d7679ddf868c7289c4",
 )
 
-new_http_archive(
+http_archive(
     name = "com_github_jbeder_yaml_cpp",
     urls = ["https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.2.tar.gz"],
     strip_prefix = "yaml-cpp-yaml-cpp-0.6.2",
-    build_file = "third_party/yaml-cpp/yaml.BUILD",
+    build_file = "@//:third_party/yaml-cpp/yaml.BUILD",
+    sha256 = "e4d8560e163c3d875fd5d9e5542b5fd5bec810febdcba61481fe5fc4e6b1fd05",
 )
 
-new_http_archive(
+http_archive(
     name = "com_github_danmar_cppcheck",
     urls = ["https://github.com/danmar/cppcheck/archive/1.87.zip"],
     strip_prefix = "cppcheck-1.87",
-    build_file = "third_party/cppcheck/cppcheck.BUILD",
+    build_file = "@//:third_party/cppcheck/cppcheck.BUILD",
+    sha256 = "b3de7fbdc1a23d7341b55f7f88877e106a76847bd5a07fa721c07310b625318b",
 )
 # end 3rdparty C++ dependencies
 
 # for helm
-new_http_archive(
+http_archive(
     name = "helm_mac",
-    url = "https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-darwin-amd64.tar.gz",
+    urls = ["https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-darwin-amd64.tar.gz"],
     strip_prefix = "darwin-amd64",
-    build_file = "third_party/helm/helm.BUILD",
+    build_file = "@//:third_party/helm/helm.BUILD",
     sha256 = "5058142bcd6e16b7e01695a8f258d27ae0b6469caf227ddf6aa2181405e6aa8e",
 )
 
-new_http_archive(
+http_archive(
     name = "helm_linux",
-    url = "https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-linux-amd64.tar.gz",
+    urls = ["https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-linux-amd64.tar.gz"],
     strip_prefix = "linux-amd64",
-    build_file = "third_party/helm/helm.BUILD",
+    build_file = "@//:third_party/helm/helm.BUILD",
     sha256 = "9f04c4824fc751d6c932ae5b93f7336eae06e78315352aa80241066aa1d66c49",
 )
 # end helm
@@ -938,54 +948,67 @@
 # for docker image building
 http_archive(
     name = "io_bazel_rules_docker",
-    urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.4.0.tar.gz"],
-    strip_prefix = "rules_docker-0.4.0",
-    sha256 = "6dede2c65ce86289969b907f343a1382d33c14fbce5e30dd17bb59bb55bb6593",
+    urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.7.0.tar.gz"],
+    strip_prefix = "rules_docker-0.7.0",
+    sha256 = "aed1c249d4ec8f703edddf35cbe9dfaca0b5f5ea6e4cd9e83e99f3b0d1136c3d",
 )
 
 load(
+    "@io_bazel_rules_docker//repositories:repositories.bzl",
+    container_repositories = "repositories",
+)
+
+container_repositories()
+
+load(
     "@io_bazel_rules_docker//container:container.bzl",
     "container_pull",
-    container_repositories = "repositories",
 )
 
-# This is NOT needed when going through the language lang_image
-# "repositories" function(s).
-container_repositories()
-
 container_pull(
     name = "heron-base",
     registry = "index.docker.io",
     repository = "heron/base",
     tag = "0.4.0",
+    digest = "sha256:495800e9eb001dfd2fb41d1941155203bb9be06b716b0f8b1b0133eb12ea813c"
 )
+
 # end docker image building
 
 # for nomad repear
-new_http_archive(
+http_archive(
     name = "nomad_mac",
     urls = ["https://releases.hashicorp.com/nomad/0.7.0/nomad_0.7.0_darwin_amd64.zip"],
-    build_file = "third_party/nomad/nomad.BUILD",
+    build_file = "@//:third_party/nomad/nomad.BUILD",
     sha256 = "53452f5bb27131f1fe5a5f9178324511bcbc54e4fef5bec4e25b049ac38e0632",
 )
 
-new_http_archive(
+http_archive(
     name = "nomad_linux",
     urls = ["https://releases.hashicorp.com/nomad/0.7.0/nomad_0.7.0_linux_amd64.zip"],
-    build_file = "third_party/nomad/nomad.BUILD",
+    build_file = "@//:third_party/nomad/nomad.BUILD",
     sha256 = "b3b78dccbdbd54ddc7a5ffdad29bce2d745cac93ea9e45f94e078f57b756f511",
 )
 
 # scala integration
-rules_scala_version="5cdae2f034581a05e23c3473613b409de5978833" # update this as needed
+rules_scala_version = "9cb85352a060248a558fedecaa46832abbb2864b"  # update this as needed
 
 http_archive(
     name = "io_bazel_rules_scala",
-    url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip" % rules_scala_version,
+    urls = ["https://github.com/bazelbuild/rules_scala/archive/%s.zip" % rules_scala_version],
     type = "zip",
-    strip_prefix= "rules_scala-%s" % rules_scala_version,
-    sha256 = "bd66b178da5b9b6845f677bdfb2594de8f1050f831a8d69527c6737969376065",
+    strip_prefix = "rules_scala-%s" % rules_scala_version,
+    sha256 = "9cbb637e913f0a19e1c781a7f163797bb5ab4cf39729ab7f90e9fc8453588712",
 )
 
 load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
-scala_repositories()
+
+scala_repositories(("2.12.8", {
+    "scala_compiler": "f34e9119f45abd41e85b9e121ba19dd9288b3b4af7f7047e86dc70236708d170",
+    "scala_library": "321fb55685635c931eba4bc0d7668349da3f2c09aee2de93a70566066ff25c28",
+    "scala_reflect": "4d6405395c4599ce04cea08ba082339e3e42135de9aae2923c9f5367e957315a"
+}))
+
+load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
+
+scala_register_toolchains()
diff --git a/heron/proto/BUILD b/heron/proto/BUILD
index 0991768..3f08a1c 100644
--- a/heron/proto/BUILD
+++ b/heron/proto/BUILD
@@ -191,7 +191,7 @@
         ":proto_ckptmgr_py",
     ],
     reqs = [
-        "protobuf==3.4.0",
+        "protobuf==3.6.1",
         "setuptools==18.0.1",
     ],
 )
diff --git a/heron/tools/tracker/src/python/BUILD b/heron/tools/tracker/src/python/BUILD
index cd9f3a2..e3744ab 100644
--- a/heron/tools/tracker/src/python/BUILD
+++ b/heron/tools/tracker/src/python/BUILD
@@ -14,7 +14,7 @@
         "//heron/proto:proto-py",
     ],
     reqs = [
-        "protobuf==3.4.0",
+        "protobuf==3.6.1",
         "tornado==4.0.2",
     ],
 )
diff --git a/heronpy/proto/BUILD b/heronpy/proto/BUILD
index 6e7ca7a..ae4d8a5 100644
--- a/heronpy/proto/BUILD
+++ b/heronpy/proto/BUILD
@@ -39,7 +39,7 @@
         ":proto_ckptmgr_py",
     ],
     reqs = [
-        "protobuf==3.4.0",
+        "protobuf==3.6.1",
         "setuptools==18.0.1",
     ],
 )
@@ -62,7 +62,7 @@
         ":proto_ckptmgr_py",
     ],
     reqs = [
-        "protobuf==3.4.0",
+        "protobuf==3.6.1",
         "setuptools==18.0.1",
     ],
 )
diff --git a/scripts/applatix/build.sh b/scripts/applatix/build.sh
index f1a9785..d7c9900 100755
--- a/scripts/applatix/build.sh
+++ b/scripts/applatix/build.sh
@@ -99,7 +99,7 @@
 python ${UTILS}/save-logs.py "heron_test_flaky.txt" bazel\
   --bazelrc=tools/applatix/bazel.rc test\
   --test_summary=detailed --test_output=errors\
-  --config=$PLATFORM --test_tag_filters=flaky --jobs=0 heron/...
+  --config=$PLATFORM --test_tag_filters=flaky --jobs=1 heron/...
 end_timer "$T"
 
 T="heron build binpkgs"
diff --git a/scripts/images/BUILD b/scripts/images/BUILD
index a98ccef..4a36ab5 100644
--- a/scripts/images/BUILD
+++ b/scripts/images/BUILD
@@ -34,7 +34,6 @@
     registry = "index.docker.io",
     repository = "tmpscratch/heron",
     tag = '{BUILD_USER}',
-    stamp = True,
 )
 
 container_push(
@@ -44,5 +43,4 @@
     registry = "index.docker.io",
     repository = "heron/heron",
     tag = '{BUILD_USER}',
-    stamp = True,
 )
diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh
index cade098..d767d3a 100755
--- a/scripts/travis/build.sh
+++ b/scripts/travis/build.sh
@@ -103,7 +103,7 @@
 python ${UTILS}/save-logs.py "heron_test_flaky.txt" bazel\
   --bazelrc=tools/travis/bazel.rc test\
   --test_summary=detailed --test_output=errors\
-  --config=$PLATFORM --test_tag_filters=flaky --jobs=0 heron/... \
+  --config=$PLATFORM --test_tag_filters=flaky --jobs=1 heron/... \
   heronpy/... examples/... storm-compatibility-examples/... \
   eco-storm-examples/... eco-heron-examples/...
 end_timer "$T"
diff --git a/tools/rules/javadoc.bzl b/tools/rules/javadoc.bzl
index 4e95c53..77633df 100644
--- a/tools/rules/javadoc.bzl
+++ b/tools/rules/javadoc.bzl
@@ -65,10 +65,10 @@
             allow_files = True,
         ),
         "_jdk": attr.label(
-            default = Label("@local_jdk//:jdk-default"),
+            default = Label("@local_jdk//:bin/javadoc"),
             allow_files = True,
         ),
     },
     outputs = {"zip": "%{name}.zip"},
     implementation = _impl,
-)
\ No newline at end of file
+)
diff --git a/tools/rules/pex/pex_rules.bzl b/tools/rules/pex/pex_rules.bzl
index 38d045b..eaf9f81 100644
--- a/tools/rules/pex/pex_rules.bzl
+++ b/tools/rules/pex/pex_rules.bzl
@@ -44,8 +44,8 @@
 so that Bazel can find your `prelude_bazel` file.
 """
 
-pex_file_types = FileType([".py"])
-egg_file_types = FileType([".egg", ".whl"])
+pex_file_types = FileType(types=[".py"])
+egg_file_types = FileType(types=[".egg", ".whl"])
 
 # As much as I think this test file naming convention is a good thing, it's
 # probably a bad idea to impose it as a policy to all OSS users of these rules,
@@ -304,8 +304,7 @@
     "eggs": attr.label_list(flags = ["DIRECT_COMPILE_TIME_INPUT"],
                             allow_files = egg_file_types),
     "reqs": attr.string_list(),
-    "data": attr.label_list(allow_files = True,
-                            cfg = "data"),
+    "data": attr.label_list(allow_files = True),
 
     # Used by pex_binary and pex_*test, not pex_library:
     "_pexbuilder": attr.label(
@@ -411,7 +410,7 @@
         "runner": attr.label(
             executable = True,
             mandatory = True,
-            cfg = "data",
+            cfg = "target",
         ),
         "launcher_template": attr.label(
             allow_files = True,