Search in sources :

Example 1 with MakePlugin

use of aQute.bnd.service.MakePlugin in project bnd by bndtools.

the class Make method process.

public Resource process(String source) {
    Map<Instruction, Map<String, String>> make = getMakeHeader();
    logger.debug("make {}", source);
    for (Map.Entry<Instruction, Map<String, String>> entry : make.entrySet()) {
        Instruction instr = entry.getKey();
        Matcher m = instr.getMatcher(source);
        if (m.matches() || instr.isNegated()) {
            Map<String, String> arguments = replace(m, entry.getValue());
            List<MakePlugin> plugins = builder.getPlugins(MakePlugin.class);
            for (MakePlugin plugin : plugins) {
                try {
                    Resource resource = plugin.make(builder, source, arguments);
                    if (resource != null) {
                        logger.debug("Made {} from args {} with {}", source, arguments, plugin);
                        return resource;
                    }
                } catch (Exception e) {
                    builder.exception(e, "Plugin %s generates error when use in making %s with args %s", plugin, source, arguments);
                }
            }
        }
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) MakePlugin(aQute.bnd.service.MakePlugin) Resource(aQute.bnd.osgi.Resource) Instruction(aQute.bnd.osgi.Instruction) Map(java.util.Map)

Aggregations

Instruction (aQute.bnd.osgi.Instruction)1 Resource (aQute.bnd.osgi.Resource)1 MakePlugin (aQute.bnd.service.MakePlugin)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1