Search in sources :

Example 41 with Builder

use of aQute.bnd.osgi.Builder in project bnd by bndtools.

the class BuilderTest method testMultipleExport2.

public static void testMultipleExport2() throws Exception {
    File[] cp = { IO.getFile("jar/asm.jar") };
    Builder bmaker = new Builder();
    try {
        Properties p = new Properties();
        p.setProperty("Export-Package", "org.objectweb.asm;version=1.1, org.objectweb.asm;version=1.2, org.objectweb.asm;version=2.3");
        bmaker.setProperties(p);
        bmaker.setClasspath(cp);
        Jar jar = bmaker.build();
        assertTrue(bmaker.check());
        jar.getManifest().write(System.err);
        Manifest m = jar.getManifest();
        m.write(System.err);
        String ip = m.getMainAttributes().getValue("Export-Package");
        assertTrue(ip.indexOf("org.objectweb.asm;version=\"1.1\"") >= 0);
        assertTrue(ip.indexOf("org.objectweb.asm;version=\"1.2\"") >= 0);
        assertTrue(ip.indexOf("org.objectweb.asm;version=\"2.3\"") >= 0);
    } finally {
        bmaker.close();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Properties(java.util.Properties) Manifest(java.util.jar.Manifest) File(java.io.File)

Example 42 with Builder

use of aQute.bnd.osgi.Builder in project bnd by bndtools.

the class ClassParserTest method testJavaTypeAnnotations.

/**
	 * Java Type & Parameter annotations
	 * 
	 * @throws Exception
	 */
public void testJavaTypeAnnotations() throws Exception {
    Builder b = new Builder();
    b.addClasspath(IO.getFile("java8/type_annotations/bin"));
    b.setExportPackage("reference.*");
    Jar build = b.build();
    assertTrue(b.check());
    assertTrue(b.getImports().containsFQN("runtime.annotations"));
    assertTrue(b.getImports().containsFQN("runtime.annotations.repeated"));
    assertFalse(b.getImports().containsFQN("invisible.annotations"));
    assertFalse(b.getImports().containsFQN("invisible.annotations.repeated"));
    assertEquals("reference.runtime.annotations.Foo,reference.runtime.annotations.ReferenceRuntime", b.getReplacer().process("${sort;${classes;ANNOTATION;runtime.annotations.RuntimeTypeAnnotation}}"));
    assertEquals("reference.invisible.annotations.ReferenceInvisible", b.getReplacer().process("${sort;${classes;ANNOTATION;invisible.annotations.InvisibleParameterAnnotation}}"));
    assertEquals("reference.runtime.annotations.ReferenceRuntime", b.getReplacer().process("${sort;${classes;ANNOTATION;runtime.annotations.RuntimeParameterAnnotation}}"));
    assertEquals("reference.invisible.annotations.ReferenceInvisible", b.getReplacer().process("${sort;${classes;ANNOTATION;invisible.annotations.InvisibleTypeAnnotation}}"));
    assertEquals("reference.invisible.annotations.ReferenceInvisible", b.getReplacer().process("${sort;${classes;ANNOTATION;invisible.annotations.InvisibleRepeatedAnnotation}}"));
    assertEquals("reference.runtime.annotations.ReferenceRuntime", b.getReplacer().process("${sort;${classes;ANNOTATION;runtime.annotations.RuntimeRepeatedAnnotation}}"));
    b.close();
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar)

Example 43 with Builder

use of aQute.bnd.osgi.Builder in project bnd by bndtools.

the class ClasspathTest method testSimple.

/**
	 * Test if we can use URLs on the classpath
	 * 
	 * @throws Exception
	 */
public static void testSimple() throws Exception {
    Properties p = new Properties();
    p.put("-classpath", IO.getFile("jar/osgi.jar").toURI().toURL().toString());
    p.put("Export-Package", "org.osgi.service.event");
    p.put("Private-Package", "test.refer");
    Builder b = new Builder();
    b.setClasspath(new String[] { "bin" });
    b.setProperties(p);
    Jar jar = b.build();
    Manifest m = jar.getManifest();
    String importPackage = m.getMainAttributes().getValue("Import-Package");
    assertTrue(importPackage.contains("org.osgi.framework;version=\"[1.3,2)\""));
    assertTrue(importPackage.contains("org.osgi.service.event;version=\"[1.0,2)\""));
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Properties(java.util.Properties) Manifest(java.util.jar.Manifest)

Example 44 with Builder

use of aQute.bnd.osgi.Builder in project bnd by bndtools.

the class ClasspathTest method testBundleClasspath.

/**
	 * Test if we can refer to the jars on the classpath by their file name (
	 * ignoring the path)
	 * 
	 * @throws Exception
	 */
public static void testBundleClasspath() throws Exception {
    Builder b = new Builder();
    b.setProperty("Include-Resource", "bin=bin");
    b.setProperty("Bundle-Classpath", "bin");
    Jar jar = b.build();
    // from
    assertNotNull(jar.getResource("bin/test/activator/Activator.class"));
// test.jar
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar)

Example 45 with Builder

use of aQute.bnd.osgi.Builder in project bnd by bndtools.

the class BuilderTest method setup.

public static Manifest setup(Properties p, File f) throws Exception {
    File[] cp = { IO.getFile("jar/asm.jar") };
    Builder bmaker = new Builder();
    if (f != null)
        bmaker.setProperties(f);
    else
        bmaker.setProperties(p);
    bmaker.setClasspath(cp);
    Jar jar = bmaker.build();
    assertTrue(bmaker.check());
    Manifest m = jar.getManifest();
    return m;
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Manifest(java.util.jar.Manifest) File(java.io.File)

Aggregations

Builder (aQute.bnd.osgi.Builder)426 Jar (aQute.bnd.osgi.Jar)225 File (java.io.File)197 Manifest (java.util.jar.Manifest)93 Properties (java.util.Properties)91 Resource (aQute.bnd.osgi.Resource)82 Attributes (java.util.jar.Attributes)43 DocumentBuilder (javax.xml.parsers.DocumentBuilder)41 XmlTester (aQute.bnd.test.XmlTester)39 Parameters (aQute.bnd.header.Parameters)35 Document (org.w3c.dom.Document)27 Attrs (aQute.bnd.header.Attrs)21 JarResource (aQute.bnd.osgi.JarResource)20 LogService (org.osgi.service.log.LogService)17 Domain (aQute.bnd.osgi.Domain)16 ArrayList (java.util.ArrayList)13 Project (aQute.bnd.build.Project)10 Baseline (aQute.bnd.differ.Baseline)9 Packages (aQute.bnd.osgi.Packages)9 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)9