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;
}
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;
}
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);
}
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");
}
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;
}
Aggregations