use of aQute.bnd.header.Parameters 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;
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class BndrunResolveContext method loadProvidedCapabilities.
private void loadProvidedCapabilities(ResourceBuilder system) throws Exception {
//
// Some capabilities are provided by the runtime, like native
// code.
// We need to add them here so the resolver is aware of them
//
Parameters providedCapabilities = new Parameters(properties.mergeProperties(Constants.RUNPROVIDEDCAPABILITIES), project);
system.addProvideCapabilities(providedCapabilities);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class BuilderTest method testMacroBasedExpansion.
/**
* This test checks if
*
* @throws Exception
*/
public static void testMacroBasedExpansion() throws Exception {
Processor proc = new Processor();
Builder builder = new Builder(proc);
try {
builder.setProperty("Export-Package", "${spec.packages}");
proc.setProperty("spec.packages", "${core.packages}, ${cmpn.packages}, ${mobile.packages}");
proc.setProperty("core.specs", "org.osgi.service.packageadmin, org.osgi.service.permissionadmin");
proc.setProperty("core.packages", "${replace;${core.specs};.+;$0.*}");
proc.setProperty("cmpn.specs", "org.osgi.service.event, org.osgi.service.cu");
proc.setProperty("cmpn.packages", "${replace;${cmpn.specs};.+;$0.*}");
proc.setProperty("mobile.specs", "org.osgi.service.wireadmin, org.osgi.service.log, org.osgi.service.cu");
proc.setProperty("mobile.packages", "${replace;${mobile.specs};.+;$0.*}");
builder.addClasspath(IO.getFile("jar/osgi.jar"));
Jar jar = builder.build();
// The total set is not uniqued so we're having an unused pattern
// this could be solved with ${uniq;${spec.packages}} but this is
// just
// another test
assertTrue(builder.check("Unused Export-Package instructions: \\[org.osgi.service.cu.\\*~\\]"));
Domain domain = Domain.domain(jar.getManifest());
Parameters h = domain.getExportPackage();
assertTrue(h.containsKey("org.osgi.service.cu"));
assertTrue(h.containsKey("org.osgi.service.cu.admin"));
} finally {
builder.close();
proc.close();
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class ContractTest method testUnused.
/**
* Make sure we do not add a contract if not used
*
* @throws Exception
*/
public void testUnused() throws Exception {
Jar bjara = getContractExporter("atest", "2.5", "${exports}");
Builder a = newBuilder();
a.setTrace(true);
a.addClasspath(bjara);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("test.packageinfo,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check());
Domain domain = Domain.domain(ajar.getManifest());
Parameters p = domain.getRequireCapability();
p.remove("osgi.ee");
assertEquals(0, p.size());
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class ContractTest method testSimple.
public void testSimple() throws Exception {
Jar bjar = getContractExporter("test", "2.5", "${exports}");
Builder a = newBuilder();
a.setTrace(true);
a.addClasspath(bjar);
a.setProperty(Constants.CONTRACT, "*");
a.setImportPackage("org.osgi.service.cm,*");
a.setProperty("Export-Package", "test.refer");
Jar ajar = a.build();
assertTrue(a.check());
Domain domain = Domain.domain(ajar.getManifest());
Parameters rc = domain.getRequireCapability();
rc.remove("osgi.ee");
System.out.println(rc);
assertEquals(1, rc.size());
Packages ps = a.getImports();
assertTrue(ps.containsFQN("org.osgi.service.cm"));
Attrs attrs = ps.getByFQN("org.osgi.service.cm");
assertNotNull(attrs);
assertNull(attrs.getVersion());
}
Aggregations