Adding src/main/webapp resources to WARs

This fixes onos-gui, so now onos-rest and onos-gui work.
We also exclude duplicate resources in the output jar.

Change-Id: I5fef1376a9f7e88cb7248a606e8f568f641ab45b
diff --git a/bucklets/onos.bucklet b/bucklets/onos.bucklet
index ee4b17d..ba2ed17 100644
--- a/bucklets/onos.bucklet
+++ b/bucklets/onos.bucklet
@@ -1,6 +1,8 @@
 import random
 
 DEBUG_ARG='JAVA_TOOL_OPTIONS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=y"'
+FORCE_INSTALL=True
+NONE='NONE'
 
 def osgi_jar(
     name,
@@ -12,7 +14,10 @@
     license = 'NONE',
     description = '',
     debug = False,
-    web_context = 'NONE',
+    import_packages = '*',
+    export_packages = '*',
+    include_resources = NONE,
+    web_context = NONE,
     **kwargs
     ):
 
@@ -37,6 +42,9 @@
            group_id,                          #group id
            version,                           #version
            license,                           #license url
+           "'%s'" % import_packages,          #packages to import
+           "'%s'" % export_packages,          #packages to export
+           include_resources,                 #custom includes to classpath
            web_context,                       #web context (REST API only)
            description,                       #description
           )
@@ -55,6 +63,7 @@
     name = osgi_jar_name,
     bash = bash,
     out = name + '.jar',
+    srcs =  glob(['src/main/webapp/**']),
     visibility = [], #intentially, not visible
   )
 
@@ -89,9 +98,11 @@
                        '-DartifactId=%s' % name,
                        '-Dversion=%s' % version,
                        '-Dpackaging=jar' ))
-  # TODO This rule must be run every time, adding random number as rule input.
-  #      We should make this configurable, perhaps with a flag.
-  cmd = 'FOO=%s ' % random.random() + mvn_cmd + ' > $OUT'
+  cmd = mvn_cmd + ' > $OUT'
+  if FORCE_INSTALL:
+    # Add a random number to the command to force this rule to run.
+    # TODO We should make this configurable from CLI, perhaps with a flag.
+    cmd = 'FOO=%s ' % random.random() + cmd
   genrule(
     name = name + '-install',
     bash = cmd,