use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class P2Impl method addPaths.
private void addPaths(String p, List<URI> index, URI base) {
Parameters content = new Parameters(p);
for (String path : content.keySet()) {
if ("!".equals(path)) {
break;
}
URI sub = base.resolve(path);
index.add(sub);
}
}
use of aQute.bnd.header.Parameters in project bndtools by bndtools.
the class Printer method printComponents.
/**
* Print the components in this JAR.
*
* @param jar
*/
private void printComponents(Jar jar) throws Exception {
out.println("[COMPONENTS]");
Manifest manifest = jar.getManifest();
if (manifest == null) {
out.println("No manifest");
return;
}
String componentHeader = manifest.getMainAttributes().getValue(Constants.SERVICE_COMPONENT);
Parameters clauses = new Parameters(componentHeader);
boolean printed = false;
for (String path : clauses.keySet()) {
printed = true;
out.println(path);
Resource r = jar.getResource(path);
if (r != null) {
IO.copy(IO.reader(r.openInputStream(), Constants.DEFAULT_CHARSET), or);
} else {
out.println(" - no resource");
warning("No Resource found for service component: " + path);
}
}
if (printed) {
out.println();
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AnalyzerTest method testGenerateManifest.
/**
* Fastest way to create a manifest
*
* @throws Exception
*/
public static void testGenerateManifest() throws Exception {
Analyzer analyzer = new Analyzer();
try {
Jar bin = new Jar(IO.getFile("jar/osgi.jar"));
bin.setManifest(new Manifest());
analyzer.setJar(bin);
analyzer.addClasspath(IO.getFile("jar/spring.jar"));
analyzer.setProperty("Bundle-SymbolicName", "org.osgi.core");
analyzer.setProperty("Export-Package", "org.osgi.framework,org.osgi.service.event");
analyzer.setProperty("Bundle-Version", "1.0.0.x");
analyzer.setProperty("Import-Package", "*");
Manifest manifest = analyzer.calcManifest();
assertTrue(analyzer.check());
manifest.write(System.err);
Domain main = Domain.domain(manifest);
Parameters export = main.getExportPackage();
Parameters expected = new Parameters("org.osgi.framework;version=\"1.3\",org.osgi.service.event;uses:=\"org.osgi.framework\";version=\"1.0.1\"");
assertTrue(expected.isEqual(export));
assertEquals("1.0.0.x", manifest.getMainAttributes().getValue("Bundle-Version"));
} finally {
analyzer.close();
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AnalyzerTest method testExportForJar.
/**
* There was an export generated for a jar file.
*
* @throws Exception
*/
public static void testExportForJar() throws Exception {
try (Analyzer an = new Analyzer()) {
Jar jar = new Jar("dot");
jar.putResource("target/aopalliance.jar", new FileResource(IO.getFile("jar/asm.jar")));
an.setJar(jar);
an.setProperty("Export-Package", "target");
Manifest manifest = an.calcManifest();
assertTrue(an.check());
String exports = manifest.getMainAttributes().getValue(Analyzer.EXPORT_PACKAGE);
Parameters map = Analyzer.parseHeader(exports, null);
assertEquals(1, map.size());
assertEquals("target", map.keySet().iterator().next());
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class MavenTest method testPomParser.
/**
* Test the pom parser which will turn the pom into a set of properties,
* which will make it actually readable according to some.
*
* @throws Exception
*/
@SuppressWarnings("restriction")
public static void testPomParser() throws Exception {
PomParser parser = new PomParser();
Properties p = parser.getProperties(IO.getFile("testresources/ws/maven1/pom.xml"));
p.store(System.err, "testing");
assertEquals("Apache Felix Metatype Service", p.get("pom.name"));
// is from
assertEquals("org.apache.felix", p.get("pom.groupId"));
// parent
assertEquals("org.apache.felix.metatype", p.get("pom.artifactId"));
assertEquals("bundle", p.get("pom.packaging"));
Parameters map = parser.parseHeader(p.getProperty("pom.scope.test"));
Map<String, String> junit = map.get("junit.junit");
assertNotNull(junit);
assertEquals("4.0", junit.get("version"));
Map<String, String> easymock = map.get("org.easymock.easymock");
assertNotNull(easymock);
assertEquals("2.4", easymock.get("version"));
}
Aggregations