use of aQute.bnd.service.action.Action in project bnd by bndtools.
the class Project method fillActions.
public void fillActions(Map<String, Action> all) {
List<NamedAction> plugins = getPlugins(NamedAction.class);
for (NamedAction a : plugins) all.put(a.getName(), a);
Parameters actions = new Parameters(getProperty("-actions", DEFAULT_ACTIONS), this);
for (Entry<String, Attrs> entry : actions.entrySet()) {
String key = Processor.removeDuplicateMarker(entry.getKey());
Action action;
if (entry.getValue().get("script") != null) {
// TODO check for the type
action = new ScriptAction(entry.getValue().get("type"), entry.getValue().get("script"));
} else {
action = new ReflectAction(key);
}
String label = entry.getValue().get("label");
all.put(label.toLowerCase(), action);
}
}
use of aQute.bnd.service.action.Action in project bnd by bndtools.
the class Project method action.
public void action(String command, Object... args) throws Exception {
Map<String, Action> actions = getActions();
Action a = actions.get(command);
if (a == null)
a = new ReflectAction(command);
before(this, command);
try {
if (args.length == 0)
a.execute(this, command);
else
a.execute(this, args);
} catch (Exception t) {
after(this, command, t);
throw t;
}
}
use of aQute.bnd.service.action.Action in project bnd by bndtools.
the class bnd method _project.
@Description("Execute a Project action, or if no parms given, show information about the project")
public void _project(projectOptions options) throws Exception {
Project project = getProject(options.project());
if (project == null) {
messages.NoProject();
return;
}
List<String> l = new ArrayList<String>(options._arguments());
if (l.isEmpty()) {
err.printf("Name %s\n", project.getName());
err.printf("Actions %s\n", project.getActions().keySet());
err.printf("Directory %s\n", project.getBase());
err.printf("Depends on %s\n", project.getDependson());
err.printf("Sub builders %s\n", project.getSubBuilders());
return;
}
String cmd = null;
String arg = null;
if (!l.isEmpty())
cmd = l.remove(0);
if (!l.isEmpty())
arg = l.remove(0);
if (!l.isEmpty()) {
messages.MoreArgumentsThanNeeded_(options._arguments());
return;
}
if (cmd == null) {
messages.NoCommandForProject(project);
return;
}
Action a = project.getActions().get(cmd);
if (a != null) {
a.execute(project, arg);
getInfo(project);
return;
}
}
Aggregations