Adding support for custom model registrator and supporting Java code
to be built and packaged along with the auto-generated artifacts that
represent the YANG model.

Change-Id: I62c121f22680d483df40662da6a73c1bae43826b
diff --git a/bucklets/yang.bucklet b/bucklets/yang.bucklet
index 7769fe4..91e31b1 100644
--- a/bucklets/yang.bucklet
+++ b/bucklets/yang.bucklet
@@ -23,6 +23,7 @@
     description = None,
     deps = [],
     required_apps = [],
+    custom_registrator = False,
     **kwargs
     ):
 
@@ -51,22 +52,32 @@
       out = 'yang'
     )
 
-    genrule(
-      name = registrator,
-      srcs = [ ':' + yangSrcs ],
-      cmd = '$(location //buck-tools:yang-registrator) $OUT ' + app_name + ' $SRCS',
-      out = 'YangModelRegistrator.java'
-    )
-
-    osgi_jar(
-      name = name,
-      srcs = [ ':' + yangSrcs, ':' + registrator ],
-      deps = deps + YANG_TOOLS,
-      resources = [ ':' + schema ],
-      resources_root = ".",
-      do_checkstyle = False,
-      do_javadocs = False,
-    )
+    if custom_registrator:
+        osgi_jar(
+          name = name,
+          srcs = [ ':' + yangSrcs ] + glob(['src/main/java/**/*.java']),
+          deps = deps + YANG_TOOLS,
+          resources = [ ':' + schema ],
+          resources_root = ".",
+          do_checkstyle = False,
+          do_javadocs = False,
+        )
+    else:
+        genrule(
+          name = registrator,
+          srcs = [ ':' + yangSrcs ],
+          cmd = '$(location //buck-tools:yang-registrator) $OUT ' + app_name + ' $SRCS',
+          out = 'YangModelRegistrator.java'
+        )
+        osgi_jar(
+          name = name,
+          srcs = [ ':' + yangSrcs, ':' + registrator ],
+          deps = deps + YANG_TOOLS,
+          resources = [ ':' + schema ],
+          resources_root = ".",
+          do_checkstyle = False,
+          do_javadocs = False,
+        )
 
     onos_app (
       app_name = app_name,