[onos-6359] Phase-1 - Added changes to onos.jar to support embedded dependencies
[onos-6359] Uploaded patchset 2 addressing review comments

Change-Id: I9fb3ab6c144c0e1240a44a0542e79a4641a34e54
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java
index a1f3a5f..6127acd 100644
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java
+++ b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java
@@ -31,6 +31,7 @@
 import com.facebook.buck.step.Step;
 import com.facebook.buck.step.StepExecutionResult;
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -76,6 +77,7 @@
     private String importPackages;
     private String privatePackages;
     private String dynamicimportPackages;
+    private String embeddedDependencies;
 
     private String exportPackages;
     private String includeResources;
@@ -102,6 +104,7 @@
                        String includeResources,
                        String webContext,
                        String dynamicimportPackages,
+                       String embeddedDependencies,
                        String bundleDescription,
                        String privatePackages) {
         this.inputJar = inputJar;
@@ -125,6 +128,7 @@
         this.importPackages = importPackages;
         this.privatePackages = privatePackages;
         this.dynamicimportPackages = dynamicimportPackages;
+        this.embeddedDependencies = embeddedDependencies;
         this.exportPackages = exportPackages;
         this.includeResources = includeResources;
 
@@ -166,6 +170,15 @@
             analyzer.setProperty(Analyzer.INCLUDE_RESOURCE, includeResources);
         }
 
+        if(embeddedDependencies != null) {
+            analyzer.setProperty(Analyzer.BUNDLE_CLASSPATH,
+                                 embeddedDependencies);
+            String finalIncludes = Strings.isNullOrEmpty(includeResources) ?
+                    embeddedDependencies : (includeResources+","+embeddedDependencies);
+            analyzer.setProperty(Analyzer.INCLUDE_RESOURCE,
+                                 finalIncludes);
+        }
+
         if (isWab()) {
             analyzer.setProperty(Analyzer.WAB, "src/main/webapp/");
             analyzer.setProperty("Web-ContextPath", webContext);
@@ -203,7 +216,7 @@
             //addLocalPackages(new File(classesDir.toString()), analyzer);
 
             //add resources.
-            if (includeResources != null) {
+            if (includeResources != null || embeddedDependencies != null) {
                 doIncludeResources(analyzer);
             }
 
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java
index 620182b..f69539b 100644
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java
+++ b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java
@@ -248,7 +248,7 @@
                                                            args.groupId, args.bundleName, args.bundleVersion,
                                                            args.bundleLicense, args.bundleDescription, args.importPackages,
                                                            args.exportPackages, includedResourcesString,
-                                                           args.dynamicimportPackages, args.privatePackages),
+                                                           args.dynamicimportPackages, args.privatePackages, args.embeddedDependencies),
                                     args.resourcesRoot,
                                     args.manifestFile,
                                     args.mavenCoords,
@@ -329,5 +329,6 @@
         public Optional<String> exportPackages;
         public Optional<ImmutableSortedMap<String, SourcePath>> includeResources;
         public Optional<String> dynamicimportPackages;
+        public Optional<String> embeddedDependencies;
     }
 }
\ No newline at end of file
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java
index fff225e3..b8daa45 100644
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java
+++ b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java
@@ -61,6 +61,7 @@
     private final String exportPackages;
     private final String includeResources;
     private final String dynamicimportPackages;
+    private final String embeddedDependencies;
 
     public OnosJarStepFactory(JavacOptions javacOptions,
                               JavacOptionsAmender amender,
@@ -79,7 +80,8 @@
                               Optional<String> exportPackages,
                               Optional<String> includeResources,
                               Optional<String> dynamicimportPackages,
-                              Optional<String> privatePackages) {
+                              Optional<String> privatePackages,
+                              Optional<String> embeddedDependencies) {
         super(javacOptions, amender);
         this.bundleDescription = processParameter(bundleDescription);
         this.importPackages = processParameter(importPackages);
@@ -97,6 +99,7 @@
         this.apiPackage = processParameter(apiPackage);
         this.apiDescription = processParameter(apiDescription);
         this.resources = resources;
+        this.embeddedDependencies = processParameter(embeddedDependencies);
     }
 
     private String processParameter(Optional<String> p) {
@@ -197,6 +200,7 @@
                 includeResources, // include resources
                 webContext, // web context
                 dynamicimportPackages, // dynamic import packages
+                embeddedDependencies, // embedded dependencies
                 bundleDescription,  // bundle description
                 privatePackages // private packages
         );