Search in sources :

Example 81 with Parameters

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);
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) URI(java.net.URI)

Example 82 with Parameters

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();
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) Resource(aQute.bnd.osgi.Resource) Manifest(java.util.jar.Manifest)

Example 83 with Parameters

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();
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) Jar(aQute.bnd.osgi.Jar) Analyzer(aQute.bnd.osgi.Analyzer) Manifest(java.util.jar.Manifest) Domain(aQute.bnd.osgi.Domain)

Example 84 with Parameters

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());
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) FileResource(aQute.bnd.osgi.FileResource) Jar(aQute.bnd.osgi.Jar) Analyzer(aQute.bnd.osgi.Analyzer) Manifest(java.util.jar.Manifest)

Example 85 with Parameters

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"));
}
Also used : PomParser(aQute.bnd.maven.PomParser) Parameters(aQute.bnd.header.Parameters) Properties(java.util.Properties)

Aggregations

Parameters (aQute.bnd.header.Parameters)157 Attrs (aQute.bnd.header.Attrs)78 File (java.io.File)45 Jar (aQute.bnd.osgi.Jar)44 Manifest (java.util.jar.Manifest)39 Builder (aQute.bnd.osgi.Builder)35 Domain (aQute.bnd.osgi.Domain)24 ArrayList (java.util.ArrayList)20 Map (java.util.Map)16 Attributes (java.util.jar.Attributes)16 IOException (java.io.IOException)14 HashMap (java.util.HashMap)13 Version (aQute.bnd.version.Version)11 Instructions (aQute.bnd.osgi.Instructions)9 HashSet (java.util.HashSet)9 Requirement (org.osgi.resource.Requirement)9 FileNotFoundException (java.io.FileNotFoundException)8 Properties (java.util.Properties)8 Matcher (java.util.regex.Matcher)8 Analyzer (aQute.bnd.osgi.Analyzer)7