Search in sources :

Example 1 with Exporter

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);
            }
        }
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) Attrs(aQute.bnd.header.Attrs) FileResource(aQute.bnd.osgi.FileResource) Resource(aQute.bnd.osgi.Resource) Run(aQute.bnd.build.Run) Exporter(aQute.bnd.service.export.Exporter) Project(aQute.bnd.build.Project) File(java.io.File) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Aggregations

Project (aQute.bnd.build.Project)1 Run (aQute.bnd.build.Run)1 Attrs (aQute.bnd.header.Attrs)1 Parameters (aQute.bnd.header.Parameters)1 FileResource (aQute.bnd.osgi.FileResource)1 Resource (aQute.bnd.osgi.Resource)1 Exporter (aQute.bnd.service.export.Exporter)1 MultiMap (aQute.lib.collections.MultiMap)1 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1