use of aQute.bnd.osgi.repository.AggregateRepository in project bnd by bndtools.
the class BndrunResolveContext method loadRepositories.
/**
* Load all the OSGi repositories from our registry
* <p>
* TODO Use Instruction ...
*
* @return
* @throws Exception
*/
private Processor loadRepositories() throws Exception {
//
// Get all of the repositories from the plugin registry
//
List<Repository> allRepos = registry.getPlugins(Repository.class);
Collection<Repository> orderedRepositories;
String rn = properties.mergeProperties(Constants.RUNREPOS);
if (rn == null) {
//
// No filter set, so we use all
//
orderedRepositories = allRepos;
} else {
Parameters repoNames = new Parameters(rn, project);
// Map the repository names...
Map<String, Repository> repoNameMap = new HashMap<String, Repository>(allRepos.size());
for (Repository repo : allRepos) {
String name;
if (repo instanceof aQute.bnd.deployer.repository.wrapper.Plugin) {
@SuppressWarnings("resource") aQute.bnd.deployer.repository.wrapper.Plugin wrapper = (aQute.bnd.deployer.repository.wrapper.Plugin) repo;
wrapper.init();
name = wrapper.toString();
} else if (repo instanceof RepositoryPlugin) {
name = ((RepositoryPlugin) repo).getName();
} else {
name = repo.toString();
}
repoNameMap.put(name, repo);
}
// Create the result list
orderedRepositories = new ArrayList<>();
for (String repoName : repoNames.keySet()) {
Repository repo = repoNameMap.get(repoName);
if (repo != null)
orderedRepositories.add(repo);
}
}
Processor repositoryAugments = findRepositoryAugments(orderedRepositories);
Parameters augments = new Parameters(repositoryAugments.mergeProperties(Constants.AUGMENT), project);
augments.putAll(new Parameters(properties.mergeProperties(Constants.AUGMENT), project));
if (!augments.isEmpty()) {
AggregateRepository aggregate = new AggregateRepository(orderedRepositories);
AugmentRepository augment = new AugmentRepository(augments, aggregate);
orderedRepositories = Collections.singleton((Repository) augment);
}
for (Repository repository : orderedRepositories) {
super.addRepository(repository);
}
return repositoryAugments;
}
Aggregations