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);
}
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;
}
}
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")));
}
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);
}
Aggregations