blob: 09d3d0f37ad1ceea0afc47d0819defbf024c31d8 [file] [log] [blame]
Thomas Vachuska0f7d7a42018-07-18 15:23:40 -07001# Copyright 2015 The Bazel Authors. All rights reserved.
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 _impl(ctx):
16 dir = ctx.label.name
17 jar = ctx.outputs.jar
18
19 dep_list = []
20 for dep in ctx.files.deps:
21 dep_list += [dep.path]
22
23 src_list = []
24 for src in ctx.files.srcs:
25 src_list += [src.path]
26
27 cmd = [
28 "mkdir %s" % dir,
29 "javadoc -quiet -tag onos.rsModel:a:\"onos model\" -d %s -cp %s %s" \
30 % (dir, ":".join(dep_list), " ".join(src_list)),
31 "jar cf %s -C %s ." % (jar.path, dir),
32 ]
33
34 ctx.action(
35 inputs = ctx.files.srcs + ctx.files.deps,
36 outputs = [jar],
Thomas Vachuska50ac0982018-07-19 10:17:37 -070037 progress_message = "Generating javadocs jar for %s" % ctx.attr.name,
Thomas Vachuska0f7d7a42018-07-18 15:23:40 -070038 command = ";\n".join(cmd)
39 )
40
41javadoc = rule(
42 attrs = {
43 "deps": attr.label_list(allow_files = True),
44 "srcs": attr.label_list(allow_files = True),
45 },
46 implementation = _impl,
47 outputs = {"jar" : "%{name}.jar"},
48)
49