Merge pull request #13 from fweikert:merge

PiperOrigin-RevId: 263133085
Change-Id: I539dedf283517d7f7ff81d8bc590d4bb88372056
diff --git a/WORKSPACE b/WORKSPACE
index 20ae0dc..da51813 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,18 +1,25 @@
 workspace(name = "rules_java")
 
-load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
-rules_java_dependencies()
-rules_java_toolchains()
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+http_archive(
+    name = "bazel_federation",
+    url = "https://github.com/bazelbuild/bazel-federation/archive/01dc3f937696174c9764e23978f9d2e7105fd855.zip",
+    sha256 = "64229f859bb0465fcdb654b31b3e547bbd5462005beaebbc09eb0ec735044cdd",
+    strip_prefix = "bazel-federation-01dc3f937696174c9764e23978f9d2e7105fd855",
+    type = "zip",
+)
 
+load("@bazel_federation//:repositories.bzl", "rules_java_deps")
+rules_java_deps()
+
+load("@bazel_federation//setup:rules_java.bzl", "rules_java_setup")
+rules_java_setup()
 
 #
 # Dependencies for development of rules_java itself.
 #
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-http_archive(
-    name = "rules_pkg",
-    url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.1/rules_pkg-0.2.1.tar.gz",
-    sha256 = "04c1eab736f508e94c297455915b6371432cbc4106765b5252b444d1656db051",
-)
-load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
-rules_pkg_dependencies()
+load("//:internal_deps.bzl", "rules_java_internal_deps")
+rules_java_internal_deps()
+
+load("//:internal_setup.bzl", "rules_java_internal_setup")
+rules_java_internal_setup()
diff --git a/internal_deps.bzl b/internal_deps.bzl
new file mode 100644
index 0000000..463c1f8
--- /dev/null
+++ b/internal_deps.bzl
@@ -0,0 +1,21 @@
+# Copyright 2019 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Dependencies that are needed for rules_java tests and tools."""
+
+load("@bazel_federation//:repositories.bzl", "rules_pkg")
+
+def rules_java_internal_deps():
+    """Fetches all required dependencies for rules_java tests and tools."""
+    rules_pkg()
diff --git a/internal_setup.bzl b/internal_setup.bzl
new file mode 100644
index 0000000..8c8ea19
--- /dev/null
+++ b/internal_setup.bzl
@@ -0,0 +1,18 @@
+# Copyright 2019 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Setup for rules_java tests and tools."""
+
+def rules_java_internal_setup():
+    pass  # placeholder for the federation
diff --git a/java/repositories.bzl b/java/repositories.bzl
index 6147648..93a4b92 100644
--- a/java/repositories.bzl
+++ b/java/repositories.bzl
@@ -12,6 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# WARNING: This file only exists for backwards-compatibility.
+# rules_java uses the Bazel federation, so please add any new dependencies to
+# rules_java_deps() in
+# https://github.com/bazelbuild/bazel-federation/blob/master/repositories.bzl
+# Java-only third party dependencies can be added to
+# https://github.com/bazelbuild/bazel-federation/blob/master/java_repositories.bzl
+# Ideally we'd remove anything in this file except for rules_java_toolchains(),
+# which is being invoked as part of the federation setup.
+
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")