use of aQute.bnd.service.export.Exporter in project bnd by bndtools.
the class bnd method _export.
public void _export(ExportOptions opts) throws Exception {
Project project = getProject(opts.project());
if (project == null) {
error("No project");
return;
}
// temporary
project.getWorkspace().addBasicPlugin(new SubsystemExporter());
List<Exporter> exporters = project.getPlugins(Exporter.class);
Exporter exporter = null;
for (Exporter e : exporters) {
String[] types = e.getTypes();
for (String type : types) {
if (type.equals(opts.exporter()))
;
}
}
for (String bndrun : opts._arguments()) {
File f = getFile(bndrun);
if (!f.isFile()) {
error("No such file: %s", f);
continue;
}
Run run = new Run(project.getWorkspace(), getBase(), f);
run.getSettings(this);
Parameters exports = new Parameters();
List<String> types = opts.exporter();
if (types != null) {
for (String type : types) {
exports.putAll(new Parameters(type, this));
}
} else {
String exportTypes = run.getProperty(Constants.EXPORTTYPE);
exports.putAll(new Parameters(exportTypes, this));
}
for (Entry<String, Attrs> e : exports.entrySet()) {
logger.debug("exporting {} to {} with {}", run, e.getKey(), e.getValue());
Map.Entry<String, Resource> result = run.export(e.getKey(), e.getValue());
getInfo(run);
if (result != null && isOk()) {
String name = result.getKey();
File output = new File(project.getTarget(), opts.output() == null ? name : opts.output());
if (output.isDirectory())
output = new File(output, name);
IO.mkdirs(output.getParentFile());
logger.debug("Got a result for {}, store in {}", e.getKey(), output);
IO.copy(result.getValue().openInputStream(), output);
}
}
}
}
Aggregations