Search in sources :

Example 96 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class AttributesTest method testRemoveAttribute.

/**
	 * Remove a version attribute
	 * 
	 * @throws Exception
	 */
public static void testRemoveAttribute() throws Exception {
    Jar javax = new Jar("test");
    Manifest m = new Manifest();
    m.getMainAttributes().putValue("Export-Package", "javax.microedition.io;common=split;test=abc;mandatory:=\"common,test\"");
    javax.setManifest(m);
    Jar[] cp = { javax, new Jar(IO.getFile("jar/osgi.jar")) };
    Builder bmaker = new Builder();
    Properties p = new Properties();
    p.put("Import-Package", "javax.microedition.io;common=!;test=abc,*");
    p.put("Export-Package", "org.osgi.service.io");
    bmaker.setClasspath(cp);
    bmaker.setProperties(p);
    Jar jar = bmaker.build();
    assertTrue(bmaker.check());
    jar.getManifest().write(System.err);
    Manifest manifest = jar.getManifest();
    Attributes main = manifest.getMainAttributes();
    String imprt = main.getValue("Import-Package");
    assertNotNull("Import package header", imprt);
    Parameters map = Processor.parseHeader(imprt, null);
    Map<String, String> attrs = map.get("javax.microedition.io");
    assertNotNull(attrs);
    assertNull(attrs.get("common"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Attributes(java.util.jar.Attributes) Jar(aQute.bnd.osgi.Jar) Manifest(java.util.jar.Manifest) Properties(java.util.Properties)

Example 97 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class AttributesTest method testOverrideAttribute.

/**
	 * Override a version attribute
	 * 
	 * @throws Exception
	 */
public static void testOverrideAttribute() throws Exception {
    File[] cp = { IO.getFile("jar/osgi.jar") };
    Builder bmaker = new Builder();
    Properties p = new Properties();
    p.put("Export-Package", "org.osgi.framework;version=1.1");
    bmaker.setClasspath(cp);
    bmaker.setProperties(p);
    Jar jar = bmaker.build();
    System.err.println(jar.getResources());
    // System.err.println(bmaker.getExports());
    System.err.println("Warnings: " + bmaker.getWarnings());
    System.err.println("Errors  : " + bmaker.getErrors());
    jar.getManifest().write(System.err);
    Manifest manifest = jar.getManifest();
    Attributes main = manifest.getMainAttributes();
    String export = main.getValue("Export-Package");
    assertNotNull("Export package header", export);
    Parameters map = Processor.parseHeader(export, null);
    assertEquals("1.1", map.get("org.osgi.framework").get("version"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Attributes(java.util.jar.Attributes) Jar(aQute.bnd.osgi.Jar) Properties(java.util.Properties) Manifest(java.util.jar.Manifest) File(java.io.File)

Example 98 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class AttributesTest method testSimple.

/**
	 * See if we inherit the version from the osgi.jar file.
	 * 
	 * @throws Exception
	 */
public static void testSimple() throws Exception {
    File[] cp = { IO.getFile("jar/osgi.jar") };
    Builder bmaker = new Builder();
    Properties p = new Properties();
    p.put("Export-Package", "org.osgi.framework");
    bmaker.setClasspath(cp);
    bmaker.setProperties(p);
    Jar jar = bmaker.build();
    System.err.println(jar.getResources());
    // System.err.println(bmaker.getExports());
    System.err.println("Warnings: " + bmaker.getWarnings());
    System.err.println("Errors  : " + bmaker.getErrors());
    jar.getManifest().write(System.err);
    Manifest manifest = jar.getManifest();
    Attributes main = manifest.getMainAttributes();
    String export = main.getValue("Export-Package");
    assertNotNull("Export package header", export);
    Parameters map = Processor.parseHeader(export, null);
    assertEquals("1.3", map.get("org.osgi.framework").get("version"));
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Attributes(java.util.jar.Attributes) Jar(aQute.bnd.osgi.Jar) Properties(java.util.Properties) Manifest(java.util.jar.Manifest) File(java.io.File)

Example 99 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class BuilderTest method testExportedVersionsNotPickedUp.

/**
	 * Complaint that exported versions were not picked up from external bundle.
	 */
public static void testExportedVersionsNotPickedUp() throws Exception {
    Builder b = new Builder();
    try {
        b.addClasspath(IO.getFile("jar/jsr311-api-1.1.1.jar"));
        b.setProperty("Export-Package", "javax.ws.rs.core");
        Jar jar = b.build();
        assertTrue(b.check());
        String ip = jar.getManifest().getMainAttributes().getValue(Constants.EXPORT_PACKAGE);
        Parameters map = Processor.parseHeader(ip, null);
        assertEquals("1.1.1", map.get("javax.ws.rs.core").get("version"));
    } finally {
        b.close();
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar)

Example 100 with Parameters

use of aQute.bnd.header.Parameters in project bnd by bndtools.

the class BuilderTest method testUnProvidedVersion.

public static void testUnProvidedVersion() throws Exception {
    Builder b = new Builder();
    try {
        b.addClasspath(IO.getFile("jar/osgi.jar"));
        b.addClasspath(new File("bin"));
        b.setProperty(Constants.EXPORT_PACKAGE, "org.osgi.service.event;provide:=false");
        b.setProperty("Private-Package", "test.refer");
        Jar jar = b.build();
        assertTrue(b.check());
        String ip = jar.getManifest().getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
        Parameters map = Processor.parseHeader(ip, null);
        assertEquals("[1.0,2)", map.get("org.osgi.service.event").get("version"));
    } finally {
        b.close();
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) File(java.io.File)

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