Search in sources :

Example 16 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class Analyzer method getJarFromName.

/**
	 * Try to get a Jar from a file name/path or a url, or in last resort from
	 * the classpath name part of their files.
	 * 
	 * @param name URL or filename relative to the base
	 * @param from Message identifying the caller for errors
	 * @return null or a Jar with the contents for the name
	 */
public Jar getJarFromName(String name, String from) {
    Jar j = super.getJarFromName(name, from);
    Glob g = new Glob(name);
    if (j == null) {
        for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext(); ) {
            Jar entry = cp.next();
            if (entry.getSource() == null)
                continue;
            if (g.matcher(entry.getSource().getName()).matches()) {
                return entry;
            }
        }
    }
    return j;
}
Also used : Glob(aQute.libg.glob.Glob)

Example 17 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class MavenBndRepository method list.

@Override
public List<String> list(String pattern) throws Exception {
    init();
    Glob g = pattern == null ? null : new Glob(pattern);
    List<String> bsns = new ArrayList<>();
    for (String bsn : index.list()) {
        if (g == null || g.matcher(bsn).matches())
            bsns.add(bsn);
    }
    return bsns;
}
Also used : ArrayList(java.util.ArrayList) Glob(aQute.libg.glob.Glob)

Example 18 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class Main method _remove.

@Description("Remove a command or a service from the system")
public void _remove(UninstallOptions opts) throws Exception {
    if (!jpm.hasAccess()) {
        error("No write acces, might require administrator or root privileges (sudo in *nix)");
        return;
    }
    ArrayList<String> toDelete = new ArrayList<String>();
    ArrayList<String> names = new ArrayList<String>();
    List<CommandData> commands = jpm.getCommands();
    for (CommandData command : commands) {
        names.add(command.name);
    }
    List<ServiceData> services = jpm.getServices();
    for (ServiceData service : services) {
        names.add(service.name);
    }
    for (String pattern : opts._arguments()) {
        Glob glob = new Glob(pattern);
        for (String name : names) {
            if (glob.matcher(name).matches()) {
                toDelete.add(name);
            }
        }
    }
    int ccount = 0, scount = 0;
    for (String name : toDelete) {
        Service s = null;
        if (jpm.getCommand(name) != null) {
            // Try command first
            logger.debug("Corresponding command found, removing");
            jpm.deleteCommand(name);
            ccount++;
        } else if ((s = jpm.getService(name)) != null) {
            // No command
            // matching, try
            // service
            logger.debug("Corresponding service found, removing");
            s.remove();
            scount++;
        } else {
            // No match amongst commands & services
            error("No matching command or service found for: %s", name);
        }
    }
    out.format("%d command(s) removed and %d service(s) removed%n", ccount, scount);
}
Also used : ArrayList(java.util.ArrayList) Glob(aQute.libg.glob.Glob) Service(aQute.jpm.lib.Service) CommandData(aQute.jpm.lib.CommandData) ServiceData(aQute.jpm.lib.ServiceData) Description(aQute.lib.getopt.Description)

Example 19 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class TestingMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    if (skip || skipTests) {
        return;
    }
    try {
        DependencyResolver dependencyResolver = new DependencyResolver(project, repositorySession, resolver, system);
        FileSetRepository fileSetRepository = dependencyResolver.getFileSetRepository(project.getName(), bundles, useMavenDependencies);
        if (testingSelect != null) {
            logger.info("Using selected testing file {}", testingSelect);
            testing(testingSelect, fileSetRepository);
        } else {
            Glob g = new Glob(testing == null ? "*" : testing);
            logger.info("Matching glob {}", g);
            for (File runFile : bndruns) {
                if (g.matcher(runFile.getName()).matches())
                    testing(runFile, fileSetRepository);
                else
                    logger.info("Skipping {}", g);
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
    if (errors > 0)
        throw new MojoExecutionException(errors + " errors found");
}
Also used : FileSetRepository(aQute.bnd.repository.fileset.FileSetRepository) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Glob(aQute.libg.glob.Glob) File(java.io.File) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ResolutionException(org.osgi.service.resolver.ResolutionException) DependencyResolver(aQute.bnd.maven.lib.resolve.DependencyResolver)

Example 20 with Glob

use of aQute.libg.glob.Glob in project bnd by bndtools.

the class PomResource method augmentManifest.

public String augmentManifest(Domain domain, String bsn) {
    String groupid = null;
    Parameters augments = new Parameters(processor.mergeProperties("-pomaugment"), processor);
    for (Entry<String, Attrs> augment : augments.entrySet()) {
        Glob g = new Glob(augment.getKey());
        if (g.matcher(bsn).matches()) {
            Attrs attrs = augment.getValue();
            for (Entry<String, String> attr : attrs.entrySet()) {
                String key = attr.getKey();
                boolean mandatory = false;
                if (key.startsWith("+")) {
                    key = key.substring(1);
                    mandatory = true;
                }
                if (key.length() > 0 && Character.isUpperCase(key.charAt(0))) {
                    if (mandatory || domain.get(key) == null) {
                        domain.set(key, attr.getValue());
                    }
                } else {
                    if ("groupid".equals(key))
                        groupid = attr.getValue();
                }
            }
            break;
        }
    }
    return groupid;
}
Also used : Parameters(aQute.bnd.header.Parameters) Attrs(aQute.bnd.header.Attrs) Glob(aQute.libg.glob.Glob)

Aggregations

Glob (aQute.libg.glob.Glob)22 ArrayList (java.util.ArrayList)11 File (java.io.File)7 Parameters (aQute.bnd.header.Parameters)3 Description (aQute.lib.getopt.Description)3 IOException (java.io.IOException)3 Project (aQute.bnd.build.Project)2 Attrs (aQute.bnd.header.Attrs)2 Domain (aQute.bnd.osgi.Domain)2 Jar (aQute.bnd.osgi.Jar)2 CommandData (aQute.jpm.lib.CommandData)2 Service (aQute.jpm.lib.Service)2 ServiceData (aQute.jpm.lib.ServiceData)2 ExtList (aQute.lib.collections.ExtList)2 InputStream (java.io.InputStream)2 SocketException (java.net.SocketException)2 URL (java.net.URL)2 Matcher (java.util.regex.Matcher)2 Container (aQute.bnd.build.Container)1 PomFromManifest (aQute.bnd.maven.PomFromManifest)1