Search in sources :

Example 16 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class bnd method _profile.

@Description("Profile management. A profile is a JAR that only contains packages and capabilities")
public void _profile(ProfileOptions options) throws Exception {
    Profiles profiles = new Profiles(this, options);
    CommandLine cmd = options._command();
    cmd.subCmd(options, profiles);
    getInfo(profiles);
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) Description(aQute.lib.getopt.Description)

Example 17 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class bnd method _remove.

@Description("Remove a project or a plugin from the workspace")
public void _remove(RemoveOptions opts) throws Exception {
    List<String> args = opts._arguments();
    String what = args.remove(0);
    Workspace ws = Workspace.findWorkspace(getBase());
    if (ws == null) {
        error("No workspace found from %s", getBase());
        return;
    }
    if ("project".equals(what)) {
        for (String pname : args) {
            Project project = ws.getProject(pname);
            if (project == null) {
                error("No such project %s", pname);
            } else
                project.remove();
        }
        getInfo(ws);
        return;
    }
    if ("workspace".equals(what)) {
        error("To delete a workspace, delete the directory");
        return;
    }
    if ("plugin".equals(what)) {
        CommandLine cl = new CommandLine(this);
        String help = cl.execute(new Plugins(this, ws), "remove", new ExtList<String>(args));
        if (help != null)
            out.println(help);
        return;
    }
}
Also used : Project(aQute.bnd.build.Project) CommandLine(aQute.lib.getopt.CommandLine) Workspace(aQute.bnd.build.Workspace) Description(aQute.lib.getopt.Description)

Example 18 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class DistroCommandTest method testMultipleCapabilitiesPerNamespace.

public void testMultipleCapabilitiesPerNamespace() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    ResourceBuilder builder = new ResourceBuilder();
    Domain manifest = Domain.domain(new Jar(distro).getManifest());
    builder.addManifest(manifest);
    Resource resource = builder.build();
    List<Capability> capabilities = resource.getCapabilities(null);
    assertNotNull(capabilities);
    List<Capability> extenderCaps = resource.getCapabilities(ExtenderNamespace.EXTENDER_NAMESPACE);
    int jspTaglibCapabilityCount = 0;
    for (Capability capability : extenderCaps) {
        Map<String, Object> attributes = capability.getAttributes();
        if ("jsp.taglib".equals(attributes.get(ExtenderNamespace.EXTENDER_NAMESPACE))) {
            jspTaglibCapabilityCount++;
        }
    }
    assertEquals(2, jspTaglibCapabilityCount);
    List<Capability> eeCaps = resource.getCapabilities(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
    assertTrue(eeCaps.size() > 0);
    Capability javaSECap = null;
    for (Capability capability : eeCaps) {
        Map<String, Object> attributes = capability.getAttributes();
        if ("JavaSE".equals(attributes.get(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE))) {
            javaSECap = capability;
        }
    }
    assertNotNull(javaSECap);
    @SuppressWarnings("null") Map<String, Object> attributes = javaSECap.getAttributes();
    assertTrue(attributes.containsKey("version"));
    @SuppressWarnings("unchecked") List<Version> versions = (List<Version>) attributes.get("version");
    assertTrue(versions.size() > 1);
    assertTrue(versions.contains(new Version("1.7.0")));
    assertTrue(versions.contains(new Version("1.6.0")));
    assertTrue(versions.contains(new Version("1.5.0")));
    assertTrue(versions.contains(new Version("1.4.0")));
    assertTrue(versions.contains(new Version("1.3.0")));
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Capability(org.osgi.resource.Capability) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) Version(org.osgi.framework.Version) Jar(aQute.bnd.osgi.Jar) ArrayList(java.util.ArrayList) List(java.util.List) Domain(aQute.bnd.osgi.Domain) File(java.io.File)

Example 19 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class DistroCommandTest method testDistroJarLastModified.

public void testDistroJarLastModified() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    if (distro.exists()) {
        assertTrue(distro.delete());
    }
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    assertTrue(distro.lastModified() > 0);
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

CommandLine (aQute.lib.getopt.CommandLine)19 Description (aQute.lib.getopt.Description)10 File (java.io.File)8 Justif (aQute.lib.justif.Justif)6 DistroOptions (aQute.bnd.main.RemoteCommand.DistroOptions)4 RemoteOptions (aQute.bnd.main.RemoteCommand.RemoteOptions)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 Formatter (java.util.Formatter)3 Workspace (aQute.bnd.build.Workspace)2 Domain (aQute.bnd.osgi.Domain)2 ExtList (aQute.lib.collections.ExtList)2 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 Sed (aQute.libg.sed.Sed)2 Reporter (aQute.service.reporter.Reporter)2 RandomAccessFile (java.io.RandomAccessFile)2 Method (java.lang.reflect.Method)2 List (java.util.List)2 Resource (org.osgi.resource.Resource)2 Project (aQute.bnd.build.Project)1