blob: 14d9f7b5da0fb8b7d8a96f87a5ecb4fe2faead8a [file] [log] [blame]
Thomas Vachuska9379a072018-08-21 14:19:02 -07001# Copyright 2018-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15def _local_jar_impl(repository_ctx):
Thomas Vachuskad389a6e2018-10-29 15:17:17 -070016 file = repository_ctx.attr.path.split("/")[-1]
17 repository_ctx.symlink(repository_ctx.attr.path, "%s" % file)
18 repository_ctx.file("BUILD", content = """
Thomas Vachuska9379a072018-08-21 14:19:02 -070019# DO NOT EDIT: automatically generated BUILD file for local_jar rule
20java_import(
Thomas Vachuskad389a6e2018-10-29 15:17:17 -070021 name = "%s",
22 jars = ["%s"],
Thomas Vachuska9379a072018-08-21 14:19:02 -070023 visibility = ['//visibility:public']
24)
Thomas Vachuskad389a6e2018-10-29 15:17:17 -070025 """ % (repository_ctx.attr.name, file))
26 repository_ctx.file("WORKSPACE", content = """
27# DO NOT EDIT: automatically generated BUILD file for local_jar rule
28workspace(name = "%s")
29 """ % repository_ctx.attr.name)
30 repository_ctx.file("jar/BUILD", content = """
31# DO NOT EDIT: automatically generated BUILD file for local_jar rule
32
33package(default_visibility = ["//visibility:public"])
34
35alias(
36 name = "jar",
37 actual = "@%s",
38)
Thomas Vachuska9379a072018-08-21 14:19:02 -070039 """ % repository_ctx.attr.name)
40
41# Workspace rule to allow override of a single locally built 3rd party jar
42local_jar = repository_rule(
43 implementation = _local_jar_impl,
44 local = True,
45 attrs = {"path": attr.string(mandatory = True)},
46)
47
48# Macro to allow building ONOS against locally-built Atomix artifacts
49def local_atomix(path, version):
50 local_jar(
51 name = "atomix",
52 path = "%s/core/target/atomix-%s.jar" % (path, version),
53 )
54 local_jar(
55 name = "atomix_cluster",
56 path = "%s/cluster/target/atomix-cluster-%s.jar" % (path, version),
57 )
58 local_jar(
59 name = "atomix_dist",
60 path = "%s/dist/target/atomix-dist-%s.jar" % (path, version),
61 )
62 local_jar(
63 name = "atomix_primitive",
64 path = "%s/primitive/target/atomix-primitive-%s.jar" % (path, version),
65 )
66 local_jar(
67 name = "atomix_tests",
68 path = "%s/tests/target/atomix-tests-%s.jar" % (path, version),
69 )
70 local_jar(
71 name = "atomix_utils",
72 path = "%s/utils/target/atomix-utils-%s.jar" % (path, version),
73 )
74 local_jar(
75 name = "atomix_agent",
76 path = "%s/agent/target/atomix-agent-%s.jar" % (path, version),
77 )
78 local_jar(
79 name = "atomix_storage",
80 path = "%s/storage/target/atomix-storage-%s.jar" % (path, version),
81 )
82 local_jar(
83 name = "atomix_gossip",
84 path = "%s/protocols/gossip/target/atomix-gossip-%s.jar" % (path, version),
85 )
86 local_jar(
87 name = "atomix_primary_backup",
88 path = "%s/protocols/primary-backup/target/atomix-primary-backup-%s.jar" % (path, version),
89 )
90 local_jar(
91 name = "atomix_raft",
92 path = "%s/protocols/raft/target/atomix-raft-%s.jar" % (path, version),
93 )
94 local_jar(
95 name = "atomix_rest",
96 path = "%s/rest/target/atomix-rest-%s.jar" % (path, version),
97 )
98
99# TODO: add local_yang_tools, etc.