Search in sources :

Example 26 with Instructions

use of aQute.bnd.osgi.Instructions in project bnd by bndtools.

the class Main method _settings.

@Description("Manage user settings of jpm (in ~/.jpm)")
public void _settings(settingOptions opts) throws Exception {
    try {
        logger.debug("settings {}", opts.clear());
        List<String> rest = opts._arguments();
        if (opts.clear()) {
            settings.clear();
            logger.debug("clear {}", settings.entrySet());
        }
        if (opts.publicKey()) {
            out.println(tos(opts.hex(), settings.getPublicKey()));
            return;
        }
        if (opts.secretKey()) {
            out.println(tos(opts.hex(), settings.getPrivateKey()));
            return;
        }
        if (opts.id()) {
            out.printf("%s\n", tos(opts.hex(), settings.getPublicKey()));
        }
        if (opts.mac()) {
            for (String s : rest) {
                byte[] data = s.getBytes(UTF_8);
                byte[] signature = settings.sign(data);
                out.printf("%s\n", tos(opts.hex(), signature));
            }
            return;
        }
        if (rest.isEmpty()) {
            list(null, settings);
        } else {
            boolean set = false;
            for (String s : rest) {
                Matcher m = ASSIGNMENT.matcher(s);
                logger.debug("try {}", s);
                if (m.matches()) {
                    logger.debug("matches {} {} {}", s, m.group(1), m.group(2));
                    String key = m.group(1);
                    Instructions instr = new Instructions(key);
                    Collection<String> select = instr.select(settings.keySet(), true);
                    String value = m.group(2);
                    if (value == null) {
                        logger.debug("list wildcard {} {} {}", instr, select, settings.keySet());
                        list(select, settings);
                    } else {
                        logger.debug("assignment 	");
                        settings.put(key, value);
                        set = true;
                    }
                } else {
                    err.printf("Cannot assign %s\n", s);
                }
            }
            if (set) {
                logger.debug("saving");
                settings.save();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Matcher(java.util.regex.Matcher) Instructions(aQute.bnd.osgi.Instructions) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) Description(aQute.lib.getopt.Description)

Example 27 with Instructions

use of aQute.bnd.osgi.Instructions in project bndtools by bndtools.

the class DeltaWrapper method hasChangedSubbundles.

public boolean hasChangedSubbundles() throws CoreException {
    if (delta == null)
        return true;
    final List<String> files = toFiles(false);
    Instructions instr = new Instructions(model.getProperty(Constants.SUB));
    Collection<String> selected = instr.select(files, false);
    return !selected.isEmpty();
}
Also used : Instructions(aQute.bnd.osgi.Instructions)

Aggregations

Instructions (aQute.bnd.osgi.Instructions)27 File (java.io.File)15 Jar (aQute.bnd.osgi.Jar)11 Description (aQute.lib.getopt.Description)10 Parameters (aQute.bnd.header.Parameters)9 Attrs (aQute.bnd.header.Attrs)6 Instruction (aQute.bnd.osgi.Instruction)6 FileResource (aQute.bnd.osgi.FileResource)5 ArrayList (java.util.ArrayList)5 Clazz (aQute.bnd.osgi.Clazz)4 Resource (aQute.bnd.osgi.Resource)4 Tree (aQute.bnd.service.diff.Tree)4 HashSet (java.util.HashSet)4 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)3 Version (aQute.bnd.version.Version)3 MultiMap (aQute.lib.collections.MultiMap)3 IOException (java.io.IOException)3 PrintWriter (java.io.PrintWriter)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Date (java.util.Date)3