Adding ability to build project über javadocs.

Change-Id: If57e8dc7a6bea62490c33bbcf635c8dab5eadba2
diff --git a/docs/BUILD b/docs/BUILD
new file mode 100644
index 0000000..883397d
--- /dev/null
+++ b/docs/BUILD
@@ -0,0 +1,312 @@
+load("//tools/build/bazel:project_javadoc.bzl", "project_javadoc")
+load("//tools/build/bazel:generate_workspace.bzl", "ONOS_VERSION", "CORE_DEPS")
+
+SOURCES = glob(["src/main/javadoc/doc-files/*"]) + [
+    "src/main/javadoc/overview.html",
+    "//utils/osgi:onlab-osgi-sources",
+    "//utils/junit:onlab-junit-sources",
+    "//utils/misc:onlab-misc-sources",
+    "//utils/rest:onlab-rest-sources",
+    "//core/api:onos-api-sources",
+    "//incubator/api:onos-incubator-api-sources",
+    "//core/net:onos-core-net-sources",
+    "//core/common:onos-core-common-sources",
+    "//core/store/primitives:onos-core-primitives-sources",
+    "//core/store/serializers:onos-core-serializers-sources",
+    "//core/store/dist:onos-core-dist-sources",
+    "//core/security:onos-security-sources",
+    "//core/store/persistence:onos-core-persistence-sources",
+    "//incubator/net:onos-incubator-net-sources",
+    "//incubator/store:onos-incubator-store-sources",
+    "//incubator/rpc:onos-incubator-rpc-sources",
+    "//cli:onos-cli-sources",
+    "//web/api:onos-rest",
+
+    "//apps/cpman/api:onos-apps-cpman-api-sources",
+    "//apps/routing-api:onos-apps-routing-api-sources",
+    "//apps/dhcp/api:onos-apps-dhcp-api-sources",
+]
+
+INTERNAL_SOURCES = [
+    "//protocols/rest/api:onos-protocols-rest-api-sources",
+    "//protocols/rest/ctl:onos-protocols-rest-ctl-sources",
+    "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio-sources",
+    "//protocols/bgp/api:onos-protocols-bgp-api-sources",
+    "//protocols/bgp/ctl:onos-protocols-bgp-ctl-sources",
+    "//protocols/netconf/api:onos-protocols-netconf-api-sources",
+    "//protocols/netconf/ctl:onos-protocols-netconf-ctl-sources",
+    "//protocols/openflow/api:onos-protocols-openflow-api-sources",
+    "//protocols/openflow/ctl:onos-protocols-openflow-ctl-sources",
+    "//protocols/ospf/api:onos-protocols-ospf-api-sources",
+    "//protocols/ospf/protocol:onos-protocols-ospf-protocol-sources",
+    "//protocols/ospf/ctl:onos-protocols-ospf-ctl-sources",
+    "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc-sources",
+    "//protocols/ovsdb/api:onos-protocols-ovsdb-api-sources",
+    "//protocols/ovsdb/ctl:onos-protocols-ovsdb-ctl-sources",
+#    "//protocols/p4runtime/api:onos-protocols-p4runtime-api-sources",
+#    "//protocols/p4runtime/model:onos-protocols-p4runtime-model-sources",
+    "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio-sources",
+    "//protocols/pcep/server/api:onos-protocols-pcep-server-api-sources",
+    "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl-sources",
+    "//protocols/snmp/api:onos-protocols-snmp-api-sources",
+    "//protocols/snmp/ctl:onos-protocols-snmp-ctl-sources",
+    "//protocols/isis/api:onos-protocols-isis-api-sources",
+    "//protocols/isis/ctl:onos-protocols-isis-ctl-sources",
+    "//protocols/isis/isisio:onos-protocols-isis-isisio-sources",
+    "//protocols/lisp/api:onos-protocols-lisp-api-sources",
+    "//protocols/lisp/ctl:onos-protocols-lisp-ctl-sources",
+    "//protocols/lisp/msg:onos-protocols-lisp-msg-sources",
+    "//protocols/tl1/api:onos-protocols-tl1-api-sources",
+    "//protocols/tl1/ctl:onos-protocols-tl1-ctl-sources",
+    "//protocols/restconf/client/api:onos-protocols-restconf-client-api-sources",
+    "//protocols/restconf/client/ctl:onos-protocols-restconf-client-ctl-sources",
+    "//protocols/xmpp/core/api:onos-protocols-xmpp-core-api-sources",
+    "//protocols/xmpp/core/ctl:onos-protocols-xmpp-core-ctl-sources",
+
+    "//drivers/utilities:onos-drivers-utilities-sources",
+
+    "//providers/netconf/device:onos-providers-netconf-device-sources",
+    "//providers/openflow/device:onos-providers-openflow-device-sources",
+    "//providers/openflow/packet:onos-providers-openflow-packet-sources",
+    "//providers/openflow/flow:onos-providers-openflow-flow-sources",
+    "//providers/openflow/group:onos-providers-openflow-group-sources",
+    "//providers/openflow/meter:onos-providers-openflow-meter-sources",
+    "//providers/ovsdb/device:onos-providers-ovsdb-device-sources",
+    "//providers/ovsdb/tunnel:onos-providers-ovsdb-tunnel-sources",
+    "//providers/rest/device:onos-providers-rest-device-sources",
+    "//providers/snmp/device:onos-providers-snmp-device-sources",
+    "//providers/isis/cfg:onos-providers-isis-cfg-sources",
+    "//providers/isis/topology:onos-providers-isis-topology-sources",
+    "//providers/lisp/device:onos-providers-lisp-device-sources",
+    "//providers/tl1/device:onos-providers-tl1-device-sources",
+    "//providers/general/device:onos-providers-general-device-sources",
+#    "//providers/p4runtime/packet:onos-providers-p4runtime-packet-sources",
+
+    "//apps/pcep-api:onos-apps-pcep-api-sources",
+    "//apps/optical-model:onos-apps-optical-model-sources",
+    "//apps/mappingmanagement/api:onos-apps-mappingmanagement-api-sources",
+]
+
+JAVADOC_DEPS = CORE_DEPS + KRYO + REST + CLI + JACKSON + TEST + NETTY + METRICS + ONOS_YANG + [
+    "@netty//jar",
+    "@netty_codec//jar",
+    "@netty_transport//jar",
+    "@netty_handler//jar",
+    "@netty_transport_native_epoll//jar",
+    "@atomix//jar",
+    "@commons_math3//jar",
+    "@joda_time//jar",
+    "@mapdb//jar",
+    "@httpclient_osgi//jar",
+    "@httpcore_osgi//jar",
+    "@bndlib//jar",
+    "@jersey_client//jar",
+    "@jersey_server//jar",
+    "@jersey_security//jar",
+    "@org_apache_felix_scr_bnd//jar",
+    "@openflowj//jar",
+    "@org_apache_servicemix_bundles_snmp4j//jar",
+    "@snmp_core//jar",
+    "@mibs_net_snmp//jar",
+    "@mibs_rfc//jar",
+    "@tinder_xmpp//jar",
+    "@aalto_xml//jar",
+    "@stax2_api//jar",
+    "@bcprov_jdk15on//jar",
+    "@bcpkix_jdk15on//jar",
+    "@sshd_core//jar",
+    "@ganymed_ssh2//jar",
+    "@concurrent_trees//jar",
+]
+
+EXTERNAL_GROUPS = {
+    "Network Model & Services": [ "org.onosproject.*" ],
+    "Incubator for Network Model & Services": [ "org.onosproject.incubator.*" ],
+    "Utilities": [ "org.onlab.*" ],
+    "App & Extensions": [
+        "org.onosproject.dhcp",
+        "org.onosproject.cpman",
+        "org.onosproject.routing",
+    ],
+}
+
+INTERNAL_GROUPS = {
+    "Network Model & Services": [ "org.onosproject.*" ],
+    "Incubator for Network Model & Services": [ "org.onosproject.incubator.*" ],
+    "Core Subsystems": [
+        "org.onosproject.cfg.impl",
+        "org.onosproject.cluster.impl",
+        "org.onosproject.core.impl",
+        "org.onosproject.event.impl",
+        "org.onosproject.net.config.impl",
+        "org.onosproject.net.device.impl",
+        "org.onosproject.net.driver.impl",
+        "org.onosproject.net.edgeservice.impl",
+        "org.onosproject.net.flow.impl",
+        "org.onosproject.net.flowobjective.impl",
+        "org.onosproject.net.flowobjective.impl.composition",
+        "org.onosproject.net.group.impl",
+        "org.onosproject.net.host.impl",
+        "org.onosproject.net.intent.impl",
+        "org.onosproject.net.intent.impl.compiler",
+        "org.onosproject.net.intent.impl.phase",
+        "org.onosproject.net.intf.impl",
+        "org.onosproject.net.link.impl",
+        "org.onosproject.net.newresource.impl",
+        "org.onosproject.net.packet.impl",
+        "org.onosproject.net.proxyarp.impl",
+        "org.onosproject.net.resource.impl",
+        "org.onosproject.net.statistic.impl",
+        "org.onosproject.net.topology.impl",
+        "org.onosproject.json",
+        "org.onosproject.json.*",
+        "org.onosproject.common.*",
+        "org.onosproject.security.impl",
+        "org.onosproject.security.store",
+    ],
+    "Distributed Stores": [
+        "org.onosproject.store.*",
+        "org.onosproject.persistence.impl",
+    ],
+    "Incubator for Core Subsystems & Distributed Stores": [
+        "org.onosproject.incubator.net.impl",
+        "org.onosproject.incubator.store.impl",
+        "org.onosproject.incubator.net.resource.label.impl",
+        "org.onosproject.incubator.store.resource.impl",
+        "org.onosproject.incubator.net.tunnel.impl",
+        "org.onosproject.incubator.store.tunnel.impl",
+        "org.onosproject.incubator.net.config.impl",
+        "org.onosproject.incubator.net.domain.impl",
+        "org.onosproject.incubator.store.config.impl",
+        "org.onosproject.incubator.net.meter.impl",
+        "org.onosproject.incubator.net.resource.label",
+        "org.onosproject.incubator.store.meter.impl",
+    ],
+    "Utilities": [ "org.onlab.*" ],
+    "GUI, REST & Command-Line": [
+        "org.onosproject.ui.impl*",
+        "org.onosproject.rest.*",
+        "org.onosproject.cli*",
+        "org.onosproject.codec.impl",
+    ],
+    "Builtin Applications": [
+        "org.onosproject.app.*",
+        "org.onosproject.acl*",
+        "org.onosproject.aaa",
+        "org.onosproject.fwd",
+        "org.onosproject.dhcp*",
+        "org.onosproject.flowanalyzer",
+        "org.onosproject.cpman*",
+        "org.onosproject.mobility",
+        "org.onosproject.proxyarp",
+        "org.onosproject.calendar",
+        "org.onosproject.olt*",
+        "org.onosproject.optical*",
+        "org.onosproject.newoptical*",
+        "org.onosproject.sdnip",
+        "org.onosproject.sdnip.*",
+        "org.onosproject.config",
+        "org.onosproject.routing",
+        "org.onosproject.routing*",
+        "org.onosproject.bgprouter",
+        "org.onosproject.segmentrouting*",
+        "org.onosproject.reactive.routing*",
+        "org.onosproject.messagingperf",
+        "org.onosproject.virtualbng*",
+        "org.onosproject.cordfabric*",
+        "org.onosproject.xosintegration*",
+        "org.onosproject.cip*",
+        "org.onosproject.vtn*",
+        "org.onosproject.cord*",
+        "org.onosproject.mcast*",
+        "org.onosproject.mfwd*",
+        "org.onosproject.mlb*",
+        "org.onosproject.igmp*",
+        "org.onosproject.pim*",
+        "org.onosproject.vpls*",
+        "org.onosproject.vrouter*",
+        "org.onosproject.faultmanagement*",
+        "org.onosproject.iptopology*",
+        "org.onosproject.drivermatrix*",
+        "org.onosproject.pathpainter*",
+        "org.onosproject.openstack*",
+        "org.onosproject.scalablegateway*",
+        "org.onosproject.forwarder*",
+        "org.onosproject.sfc*",
+        "org.onosproject.netcfgmonitor*",
+        "org.onosproject.flowperf",
+        "org.onosproject.loadtest",
+        "org.onosproject.events",
+        "org.onosproject.bmv2*",
+        "org.onosproject.xosclient*",
+        "org.onosproject.kafkaintegration*",
+        "org.onosproject.gangliametrics*",
+        "org.onosproject.graphitemetrics*",
+        "org.onosproject.influxdbmetrics*",
+        "org.onosproject.yms*",
+    ],
+    "Test Instrumentation & Applications": [
+        "org.onosproject.metrics.*",
+        "org.onosproject.demo*",
+        "org.onosproject.election*",
+        "org.onosproject.distributedprimitives*",
+        "org.onosproject.intentperf*",
+        "org.onosproject.messagingperf*",
+        "org.onosproject.optical.testapp*",
+    ],
+    "OpenFlow Providers & Controller": [
+        "org.onosproject.openflow.*",
+        "org.onosproject.provider.of.*",
+    ],
+    "NetConf Protocol & Providers": [
+        "org.onosproject.netconf*",
+        "org.onosproject.provider.netconf*",
+    ],
+    "OVSDB Protocol & Providers": [
+        "org.onosproject.provider.ovsdb*",
+        "org.onosproject.ovsdb*",
+    ],
+    "PCEP Protocol & Providers": [
+        "org.onosproject.pce.*",
+        "org.onosproject.pcerest*",
+        "org.onosproject.pceweb*",
+        "org.onosproject.pcep*",
+        "org.onosproject.pcepio*",
+        "org.onosproject.provider.pcep*",
+    ],
+    "BGP-LS Protocol & Providers": [
+        "org.onosproject.bgp.controller*",
+        "org.onosproject.bgp*",
+        "org.onosproject.provider.bgp*",
+    ],
+    "OSPF Protocol & Providers": [ "org.onosproject.ospf*" ],
+    "ISIS Protocol & Providers": [ "org.onosproject.isis*" ],
+    "LISP Protocol & Providers": [ "org.onosproject.lisp*" ],
+    "SNMP Protocol & Providers": [ "org.onosproject.snmp*" ],
+    "REST Protocol & Providers": [
+        "org.onosproject.protocol.rest*",
+        "org.onosproject.provider.rest*",
+    ],
+    "Other Providers": [
+        "org.onosproject.provider.*",
+        "org.onosproject.protocol.*",
+    ],
+    "Device Drivers": [ "org.onosproject.driver*" ],
+}
+
+project_javadoc(
+    name = "external",
+    title = "ONOS Java API (%s)" % ONOS_VERSION,
+    srcs = SOURCES,
+    deps = JAVADOC_DEPS,
+    groups = EXTERNAL_GROUPS,
+)
+
+project_javadoc(
+  name = "internal",
+  title = "ONOS Java API (%s)" % ONOS_VERSION,
+  srcs = SOURCES + INTERNAL_SOURCES,
+  deps = JAVADOC_DEPS,
+  groups = INTERNAL_GROUPS,
+  internal = True,
+)