Index: shell/obr/src/main/java/org/apache/karaf/shell/obr/DeployCommand.java =================================================================== --- shell/obr/src/main/java/org/apache/karaf/shell/obr/DeployCommand.java (revision 1376198) +++ shell/obr/src/main/java/org/apache/karaf/shell/obr/DeployCommand.java (working copy) @@ -31,9 +31,12 @@ @Option(name = "-s", aliases = { "--start" }, description = "Start all deployed bundles", required = false, multiValued = false) protected boolean start = false; + + @Option(name = "-d", aliases = { "--deployOptional" }, description = "Deploy optional bundles", required = false, multiValued = false) + protected boolean deployOptional = false; protected void doExecute(RepositoryAdmin admin) throws Exception { - doDeploy(admin, bundles, start); + doDeploy(admin, bundles, start, deployOptional); } } Index: shell/obr/src/main/java/org/apache/karaf/shell/obr/StartCommand.java =================================================================== --- shell/obr/src/main/java/org/apache/karaf/shell/obr/StartCommand.java (revision 1376198) +++ shell/obr/src/main/java/org/apache/karaf/shell/obr/StartCommand.java (working copy) @@ -16,14 +16,24 @@ */ package org.apache.karaf.shell.obr; +import java.util.List; + import org.apache.felix.bundlerepository.RepositoryAdmin; +import org.apache.felix.gogo.commands.Argument; import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; @Command(scope = "obr", name = "start", description = "Deploys and starts a list of bundles using OBR.") -public class StartCommand extends DeployCommand { +public class StartCommand extends ObrCommandSupport { + + @Argument(index = 0, name = "bundles", description = "List of bundle names to deploy (separated by whitespaces)", required = true, multiValued = true) + protected List bundles; + + @Option(name = "-d", aliases = { "--deployOptional" }, description = "Deploy optional bundles", required = false, multiValued = false) + protected boolean deployOptional = false; protected void doExecute(RepositoryAdmin admin) throws Exception { - doDeploy(admin, bundles, true); + doDeploy(admin, bundles, true, deployOptional); } } Index: shell/obr/src/main/java/org/apache/karaf/shell/obr/ObrCommandSupport.java =================================================================== --- shell/obr/src/main/java/org/apache/karaf/shell/obr/ObrCommandSupport.java (revision 1376198) +++ shell/obr/src/main/java/org/apache/karaf/shell/obr/ObrCommandSupport.java (working copy) @@ -136,7 +136,7 @@ out.println(""); } - protected void doDeploy(RepositoryAdmin admin, List bundles, boolean start) throws Exception { + protected void doDeploy(RepositoryAdmin admin, List bundles, boolean start, boolean deployOptional) throws Exception { Resolver resolver = admin.resolver(); for (String bundle : bundles) { String[] target = getTarget(bundle); @@ -153,7 +153,7 @@ if ((resolver.getAddedResources() != null) && (resolver.getAddedResources().length > 0)) { - if (resolver.resolve()) + if (resolver.resolve(deployOptional ? 0 : Resolver.NO_OPTIONAL_RESOURCES)) { System.out.println("Target resource(s):"); printUnderline(System.out, 19); @@ -174,16 +174,18 @@ + " (" + resources[resIdx].getVersion() + ")"); } } - resources = resolver.getOptionalResources(); - if ((resources != null) && (resources.length > 0)) - { - System.out.println("\nOptional resource(s):"); - printUnderline(System.out, 21); - for (int resIdx = 0; resIdx < resources.length; resIdx++) - { - System.out.println(" " + resources[resIdx].getPresentationName() - + " (" + resources[resIdx].getVersion() + ")"); - } + if (deployOptional) { + resources = resolver.getOptionalResources(); + if ((resources != null) && (resources.length > 0)) + { + System.out.println("\nOptional resource(s):"); + printUnderline(System.out, 21); + for (int resIdx = 0; resIdx < resources.length; resIdx++) + { + System.out.println(" " + resources[resIdx].getPresentationName() + + " (" + resources[resIdx].getVersion() + ")"); + } + } } try