Apply patch FELIX-3118 to add "required" option to OBR deploy command.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1172770 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java b/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java
index e46654d..debd419 100644
--- a/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java
+++ b/gogo/command/src/main/java/org/apache/felix/gogo/command/OBR.java
@@ -295,6 +295,9 @@
         @Descriptor("start deployed bundles")
         @Parameter(names={ "-s", "--start" }, presentValue="true",
             absentValue="false") boolean start,
+        @Descriptor("deploy required bundles only")
+        @Parameter(names={ "-r", "--required" }, presentValue="true",
+            absentValue="false") boolean required,
         @Descriptor("( <bundle-name> | <symbolic-name> | <bundle-id> )[@<version>] ...")
             String[] args)
         throws IOException, InvalidSyntaxException
@@ -354,22 +357,34 @@
                             + " (" + resources[resIdx].getVersion() + ")");
                     }
                 }
-                resources = resolver.getOptionalResources();
-                if ((resources != null) && (resources.length > 0))
+                if (!required)
                 {
-                    System.out.println("\nOptional resource(s):");
-                    System.out.println(Util.getUnderlineString(21));
-                    for (int resIdx = 0; resIdx < resources.length; resIdx++)
+                    resources = resolver.getOptionalResources();
+                    if ((resources != null) && (resources.length > 0))
                     {
-                        System.out.println("   " + resources[resIdx].getPresentationName()
-                            + " (" + resources[resIdx].getVersion() + ")");
+                        System.out.println("\nOptional resource(s):");
+                        System.out.println(Util.getUnderlineString(21));
+                        for (int resIdx = 0; resIdx < resources.length; resIdx++)
+                        {
+                            System.out.println("   " + resources[resIdx].getPresentationName()
+                                + " (" + resources[resIdx].getVersion() + ")");
+                        }
                     }
                 }
 
                 try
                 {
-                    System.out.print("\nDeploying...");
-                    resolver.deploy(start ? Resolver.START : 0);
+                    System.out.print("\nDeploying...\n");
+                    int options = 0;
+                    if (start)
+                    {
+                        options |= Resolver.START;
+                    }
+                    if (required)
+                    {
+                        options |= Resolver.NO_OPTIONAL_RESOURCES;
+                    }
+                    resolver.deploy(options);
                     System.out.println("done.");
                 }
                 catch (IllegalStateException ex)
@@ -649,4 +664,4 @@
         }
         return sorted;
     }
-}
\ No newline at end of file
+}