Thomas Vachuska | 0f7d7a4 | 2018-07-18 15:23:40 -0700 | [diff] [blame] | 1 | # 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 | |
Thomas Vachuska | c3226e9 | 2018-07-25 12:00:57 -0700 | [diff] [blame] | 15 | JAVA_DOCS="-link https://docs.oracle.com/javase/8/docs/api/" |
| 16 | |
Thomas Vachuska | 0f7d7a4 | 2018-07-18 15:23:40 -0700 | [diff] [blame] | 17 | def _impl(ctx): |
| 18 | dir = ctx.label.name |
| 19 | jar = ctx.outputs.jar |
| 20 | |
| 21 | dep_list = [] |
| 22 | for dep in ctx.files.deps: |
| 23 | dep_list += [dep.path] |
| 24 | |
| 25 | src_list = [] |
| 26 | for src in ctx.files.srcs: |
| 27 | src_list += [src.path] |
| 28 | |
| 29 | cmd = [ |
| 30 | "mkdir %s" % dir, |
Thomas Vachuska | c3226e9 | 2018-07-25 12:00:57 -0700 | [diff] [blame] | 31 | "javadoc -quiet -tag onos.rsModel:a:\"onos model\" %s -d %s -cp %s %s" \ |
| 32 | % (JAVA_DOCS, dir, ":".join(dep_list), " ".join(src_list)), |
Thomas Vachuska | 0f7d7a4 | 2018-07-18 15:23:40 -0700 | [diff] [blame] | 33 | "jar cf %s -C %s ." % (jar.path, dir), |
| 34 | ] |
| 35 | |
| 36 | ctx.action( |
| 37 | inputs = ctx.files.srcs + ctx.files.deps, |
| 38 | outputs = [jar], |
Thomas Vachuska | 50ac098 | 2018-07-19 10:17:37 -0700 | [diff] [blame] | 39 | progress_message = "Generating javadocs jar for %s" % ctx.attr.name, |
Thomas Vachuska | 0f7d7a4 | 2018-07-18 15:23:40 -0700 | [diff] [blame] | 40 | command = ";\n".join(cmd) |
| 41 | ) |
| 42 | |
| 43 | javadoc = rule( |
| 44 | attrs = { |
| 45 | "deps": attr.label_list(allow_files = True), |
| 46 | "srcs": attr.label_list(allow_files = True), |
| 47 | }, |
| 48 | implementation = _impl, |
| 49 | outputs = {"jar" : "%{name}.jar"}, |
| 50 | ) |
| 51 | |