Simplifying rules and providing sensible defaults

Updated cordvtn, dhcp, fwd, onos-api, of-api, onlab-rest, onos-rest, onos-gui

Also, fixed checkstyle error print

Change-Id: I9d6ab76791e8603678079067a3b4e007ca7c4667
diff --git a/bucklets/onos_app.bucklet b/bucklets/onos_app.bucklet
index ba76649..d95427e 100644
--- a/bucklets/onos_app.bucklet
+++ b/bucklets/onos_app.bucklet
@@ -1,10 +1,24 @@
 ONOS_ORIGIN = 'ON.Lab'
 ONOS_VERSION = '1.6.0-SNAPSHOT'
 DEFAULT_APP_CATEGORY = 'Utility'
+ONOS_ARTIFACT_BASE = 'onos-'
+APP_PREFIX = 'org.onosproject.'
+
+import os.path
+
+# FIXME Factor this into common place
+def _get_name():
+    base_path = get_base_path()
+    return ONOS_ARTIFACT_BASE + base_path.replace('/', '-') #TODO Unix-separator
+
+def _get_app_name():
+    base_path = get_base_path()
+    return APP_PREFIX + os.path.basename(base_path)
 
 def onos_app(
-        app_name,
-        title,
+        app_name = None,
+        name = None,
+        title = None,
         version = ONOS_VERSION,
         origin = ONOS_ORIGIN,
         category = DEFAULT_APP_CATEGORY,
@@ -14,13 +28,31 @@
         feature_coords = None,
         required_features = [ 'onos-api' ],
         required_apps = [],
-        included_bundles = [],
+        included_bundles = None,
         excluded_bundles = [],
+        visibility = [ 'PUBLIC' ],
         **kwargs):
+    if name is None:
+        name = _get_name()
+
+    if app_name is None:
+        app_name = _get_app_name()
+
+    if title is None:
+        print "Missing title for %s" % _get_name()
+        title = _get_app_name()
+
+    if included_bundles is None:
+        target = ':' + _get_name()
+        included_bundles = [ target ]
 
     if not feature_coords and len(included_bundles) == 1:
         feature_coords = '$(maven_coords %s)' % included_bundles[0]
 
+    if not feature_coords:
+        print 'Missing maven coordinates for %s app feature.' % name
+        return
+
     args = [ '-n %s' % feature_coords,
              '-v %s' % version,
              '-t "%s"' % title,
@@ -36,26 +68,27 @@
 
     cmd = '$(exe //buck-tools:onos-app-writer) -F ' + ' '.join(args) + ' > $OUT'
     genrule(
-        name = 'app-features',
+        name = name + '-features',
         bash = cmd,
         out = 'features.xml',
         visibility = [],
     )
     cmd = '$(exe //buck-tools:onos-app-writer) -A ' + ' '.join(args) + ' > $OUT'
     genrule(
-        name = 'app-xml',
+        name = name + '-app-xml',
         bash = cmd,
         out = 'app.xml',
         visibility = [],
     )
 
     sources = [
-        '$(location :app-features) %s' % feature_coords,
-        '$(location :app-xml) NONE',
+        '$(location :%s-features) %s' % (name, feature_coords),
+        '$(location :%s-app-xml) NONE' % name,
     ]
     sources += ['$(location %s) $(maven_coords %s)' % (i, i) for i in included_bundles]
     genrule(
-        name = 'app-oar',
+        name = name + '-oar',
         out = 'app.oar',
-        bash = '$(exe //buck-tools:onos-app-oar) $OUT ' + ' '.join(sources)
+        bash = '$(exe //buck-tools:onos-app-oar) $OUT ' + ' '.join(sources),
+        visibility = visibility,
     )