Top level build of component Javadocs

Change-Id: Iceb2a7c84b3dd0b354b27f93a0f746913cd9b778
diff --git a/bucklets/onos.bucklet b/bucklets/onos.bucklet
index b415fa8..9fa2190 100644
--- a/bucklets/onos.bucklet
+++ b/bucklets/onos.bucklet
@@ -46,6 +46,8 @@
                 test_rule_timeout_ms = 20000,
                 labels = [ 'checkstyle' ],
         )
+    else:
+        print 'Not generating checkstyle rule for %s because there are no sources.' % name
 
 def java_doc(
     name,
@@ -61,29 +63,34 @@
     sourcepath = paths
   else:
     sourcepath = ['$SRCDIR/' + n for n in paths]
-  genrule(
-    name = name,
+
+  if len(srcs) != 0:
     cmd = ' '.join([
-      'while ! test -f .buckconfig; do cd ..; done;',
-      'javadoc',
-      '-quiet',
-      '-protected',
-      '-encoding UTF-8',
-      '-charset UTF-8',
-      '-notimestamp',
-      '-windowtitle "' + title + '"',
-      '-link http://docs.oracle.com/javase/7/docs/api',
-      '-subpackages ',
-      ':'.join(pkgs),
-      '-sourcepath ',
-      ':'.join(sourcepath),
-      ' -classpath ',
-      ':'.join(['$(classpath %s)' % n for n in deps]),
-      '-d $TMP',
-    ]) + ';jar cf $OUT -C $TMP .',
-    srcs = srcs,
-    out = name + '.jar',
-    visibility = visibility,
+        'while ! test -f .buckconfig; do cd ..; done;',
+        'javadoc',
+        '-tag onos.rsModel:a:"onos model"',
+        '-quiet',
+        '-protected',
+        '-encoding UTF-8',
+        '-charset UTF-8',
+        '-notimestamp',
+        '-windowtitle "' + title + '"',
+        '-link http://docs.oracle.com/javase/8/docs/api',
+        '-subpackages ',
+        ':'.join(pkgs),
+        '-sourcepath ',
+        ':'.join(sourcepath),
+        ' -classpath ',
+        ':'.join(['$(classpath %s)' % n for n in deps]),
+        '-d $TMP',
+      ]) + ';jar cf $OUT -C $TMP .'
+
+    genrule(
+      name = name,
+      cmd = cmd,
+      srcs = srcs,
+      out = name + '.jar',
+      visibility = visibility,
 )
 
 
@@ -99,6 +106,7 @@
     debug = False,
     import_packages = '*',
     export_packages = '*',
+    package_name_root = 'org.onosproject',
     include_resources = NONE,
     web_context = NONE,
     resources = NONE,
@@ -187,7 +195,7 @@
   java_doc(
        name = name + '-javadoc',
        title = 'Java Docs',
-       pkgs = [ 'org.onosproject' ],
+       pkgs = [ package_name_root ],
        paths = [ 'src/main/java' ],
        srcs = srcs,
        deps = deps,
@@ -253,6 +261,9 @@
   if test_srcs is None:
       test_srcs = glob([TEST + '/*.java'])
 
+  if not test_srcs:
+          print "Generating test rule for %s, but there are no tests." % name
+
   java_test(
     name = name + '-tests',
     srcs = test_srcs,
@@ -272,6 +283,3 @@
   )
 
   #FIXME need to run checkstyle on test sources
-
-
-
diff --git a/tools/build/onos-buck-build-docs b/tools/build/onos-buck-build-docs
new file mode 100755
index 0000000..658a539
--- /dev/null
+++ b/tools/build/onos-buck-build-docs
@@ -0,0 +1,12 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Builds the ONOS Java API docs with buck.
+# -----------------------------------------------------------------------------
+
+set -e
+
+[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
+. $ONOS_ROOT/tools/build/envDefaults
+
+onos-buck build  `onos-buck query "filter('.*-javadoc', '//...')"`
+
diff --git a/utils/junit/BUCK b/utils/junit/BUCK
index 24bcf72..060d329 100644
--- a/utils/junit/BUCK
+++ b/utils/junit/BUCK
@@ -20,6 +20,7 @@
     visibility = ['PUBLIC'],
     resources_root = 'src/main/resources',
     resources = glob(['src/main/resources/**']),
+    package_name_root = 'org.onlab',
 )
 
 java_test(
diff --git a/utils/misc/BUCK b/utils/misc/BUCK
index 72dacf1..3491733 100644
--- a/utils/misc/BUCK
+++ b/utils/misc/BUCK
@@ -16,6 +16,7 @@
     srcs = glob([SRC + '/*.java']),
     deps = COMPILE_DEPS,
     visibility = ['PUBLIC'],
+    package_name_root = 'org.onlab',
 )
 
 java_test(
diff --git a/utils/osgi/BUCK b/utils/osgi/BUCK
index a661069..a19bcda 100644
--- a/utils/osgi/BUCK
+++ b/utils/osgi/BUCK
@@ -16,6 +16,7 @@
   srcs = glob([SRC + '/*.java']),
   deps = COMPILE_DEPS,
   visibility = ['PUBLIC'],
+  package_name_root = 'org.onlab',
 )
 
 java_test(
diff --git a/utils/rest/BUCK b/utils/rest/BUCK
index 27fa55d..7b08a5e 100644
--- a/utils/rest/BUCK
+++ b/utils/rest/BUCK
@@ -9,4 +9,5 @@
 osgi_jar_with_tests (
     name = 'onlab-rest',
     deps = COMPILE_DEPS,
-)
\ No newline at end of file
+    package_name_root = 'org.onlab',
+)
diff --git a/web/gui/BUCK b/web/gui/BUCK
index adf99ef..c353c60 100644
--- a/web/gui/BUCK
+++ b/web/gui/BUCK
@@ -7,6 +7,7 @@
     '//lib:jersey-media-multipart',
     '//lib:org.apache.karaf.shell.console',
     '//cli:onos-cli',
+    '//lib:jersey-server',
     '//incubator/api:onos-incubator-api',
     '//incubator/net:onos-incubator-net',
     '//utils/rest:onlab-rest',