blob: 31da241efbac05616b129b0ef195689e4bb925df [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):
16 repository_ctx.symlink(repository_ctx.attr.path, "jar/%s.jar" % repository_ctx.attr.name)
17 repository_ctx.file("jar/BUILD", content = """
18# DO NOT EDIT: automatically generated BUILD file for local_jar rule
19java_import(
20 name = "jar",
21 jars = ["%s.jar"],
22 visibility = ['//visibility:public']
23)
24 """ % repository_ctx.attr.name)
25
26# Workspace rule to allow override of a single locally built 3rd party jar
27local_jar = repository_rule(
28 implementation = _local_jar_impl,
29 local = True,
30 attrs = {"path": attr.string(mandatory = True)},
31)
32
33# Macro to allow building ONOS against locally-built Atomix artifacts
34def local_atomix(path, version):
35 local_jar(
36 name = "atomix",
37 path = "%s/core/target/atomix-%s.jar" % (path, version),
38 )
39 local_jar(
40 name = "atomix_cluster",
41 path = "%s/cluster/target/atomix-cluster-%s.jar" % (path, version),
42 )
43 local_jar(
44 name = "atomix_dist",
45 path = "%s/dist/target/atomix-dist-%s.jar" % (path, version),
46 )
47 local_jar(
48 name = "atomix_primitive",
49 path = "%s/primitive/target/atomix-primitive-%s.jar" % (path, version),
50 )
51 local_jar(
52 name = "atomix_tests",
53 path = "%s/tests/target/atomix-tests-%s.jar" % (path, version),
54 )
55 local_jar(
56 name = "atomix_utils",
57 path = "%s/utils/target/atomix-utils-%s.jar" % (path, version),
58 )
59 local_jar(
60 name = "atomix_agent",
61 path = "%s/agent/target/atomix-agent-%s.jar" % (path, version),
62 )
63 local_jar(
64 name = "atomix_storage",
65 path = "%s/storage/target/atomix-storage-%s.jar" % (path, version),
66 )
67 local_jar(
68 name = "atomix_gossip",
69 path = "%s/protocols/gossip/target/atomix-gossip-%s.jar" % (path, version),
70 )
71 local_jar(
72 name = "atomix_primary_backup",
73 path = "%s/protocols/primary-backup/target/atomix-primary-backup-%s.jar" % (path, version),
74 )
75 local_jar(
76 name = "atomix_raft",
77 path = "%s/protocols/raft/target/atomix-raft-%s.jar" % (path, version),
78 )
79 local_jar(
80 name = "atomix_rest",
81 path = "%s/rest/target/atomix-rest-%s.jar" % (path, version),
82 )
83
84# TODO: add local_yang_tools, etc.