Adding local_jar and local_deps workspace rules to allow ONOS development
against locally built 3rd party artifacts.
Change-Id: I719da113894c4e3b1513244b2b92ba510f232c90
diff --git a/WORKSPACE b/WORKSPACE
index f08f71b..28f33fe 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -4,6 +4,20 @@
check_bazel_version()
+load("//tools/build/bazel:local_jar.bzl", "local_atomix", "local_jar")
+
+# Use this to build against locally built arbitrary 3rd party artifacts
+#local_jar(
+# name = "atomix",
+# path = "/users/tom/atomix/core/target/atomix-3.0.1-SNAPSHOT.jar",
+#)
+
+# Use this to build against locally built Atomix
+#local_atomix(
+# path = "/users/tom/atomix",
+# version = "3.0.1-SNAPSHOT",
+#)
+
load("//tools/build/bazel:generate_workspace.bzl", "generated_maven_jars")
generated_maven_jars()
diff --git a/tools/build/bazel/local_jar.bzl b/tools/build/bazel/local_jar.bzl
new file mode 100644
index 0000000..31da241
--- /dev/null
+++ b/tools/build/bazel/local_jar.bzl
@@ -0,0 +1,84 @@
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+def _local_jar_impl(repository_ctx):
+ repository_ctx.symlink(repository_ctx.attr.path, "jar/%s.jar" % repository_ctx.attr.name)
+ repository_ctx.file("jar/BUILD", content = """
+# DO NOT EDIT: automatically generated BUILD file for local_jar rule
+java_import(
+ name = "jar",
+ jars = ["%s.jar"],
+ visibility = ['//visibility:public']
+)
+ """ % repository_ctx.attr.name)
+
+# Workspace rule to allow override of a single locally built 3rd party jar
+local_jar = repository_rule(
+ implementation = _local_jar_impl,
+ local = True,
+ attrs = {"path": attr.string(mandatory = True)},
+)
+
+# Macro to allow building ONOS against locally-built Atomix artifacts
+def local_atomix(path, version):
+ local_jar(
+ name = "atomix",
+ path = "%s/core/target/atomix-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_cluster",
+ path = "%s/cluster/target/atomix-cluster-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_dist",
+ path = "%s/dist/target/atomix-dist-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_primitive",
+ path = "%s/primitive/target/atomix-primitive-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_tests",
+ path = "%s/tests/target/atomix-tests-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_utils",
+ path = "%s/utils/target/atomix-utils-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_agent",
+ path = "%s/agent/target/atomix-agent-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_storage",
+ path = "%s/storage/target/atomix-storage-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_gossip",
+ path = "%s/protocols/gossip/target/atomix-gossip-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_primary_backup",
+ path = "%s/protocols/primary-backup/target/atomix-primary-backup-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_raft",
+ path = "%s/protocols/raft/target/atomix-raft-%s.jar" % (path, version),
+ )
+ local_jar(
+ name = "atomix_rest",
+ path = "%s/rest/target/atomix-rest-%s.jar" % (path, version),
+ )
+
+# TODO: add local_yang_tools, etc.