Search in sources :

Example 51 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 52 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)

Example 53 with Builder

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

the class BuilderTest method testConditionalBaseSuper.

/**
	 * Check Conditional package. First import a subpackage then let the
	 * subpackage import a super package. This went wrong in the OSGi build. We
	 * see such a pattern in the Spring jar. The package
	 * org.springframework.beans.factory.access refers to
	 * org.springframework.beans.factory and org.springframework.beans. The
	 */
public static void testConditionalBaseSuper() throws Exception {
    Builder b = new Builder();
    try {
        b.setProperty(Constants.CONDITIONALPACKAGE, "test.top.*");
        b.setProperty(Constants.PRIVATEPACKAGE, "test.top.middle.bottom");
        b.addClasspath(new File("bin"));
        Jar dot = b.build();
        assertTrue(b.check());
        assertNotNull(dot.getResource("test/top/middle/bottom/Bottom.class"));
        assertNotNull(dot.getResource("test/top/middle/Middle.class"));
        assertNotNull(dot.getResource("test/top/Top.class"));
        assertFalse(b.getImports().getByFQN("test.top") != null);
        assertFalse(b.getImports().getByFQN("test.top.middle") != null);
        assertFalse(b.getImports().getByFQN("test.top.middle.bottom") != null);
    } finally {
        b.close();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) File(java.io.File)

Example 54 with Builder

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

the class BuilderTest method testEasymock.

public static void testEasymock() throws Exception {
    File[] cp = { IO.getFile("jar/easymock.jar") };
    Builder bmaker = new Builder();
    try {
        Properties p = new Properties();
        p.put("Import-Package", "*");
        p.put("Export-Package", "*");
        p.put("Bundle-SymbolicName", "easymock");
        p.put("Bundle-Version", "2.2");
        bmaker.setProperties(p);
        bmaker.setClasspath(cp);
        Jar jar = bmaker.build();
        assertTrue(bmaker.check());
        jar.getManifest().write(System.err);
    } finally {
        bmaker.close();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Properties(java.util.Properties) File(java.io.File)

Example 55 with Builder

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

the class BuilderTest method testUpperCasePackage.

/**
	 * https://github.com/bndtools/bnd/issues/315 Turns out bnd doesn't seem to
	 * support a class in a capitalized package name. I accidentally called a
	 * package with a capital letter and I get the strange error message and a
	 * refusal to build it. (See title for error message) My package could be
	 * named "Coffee" and the package named "CoffeeClient", The bnd.bnd file
	 * could have: Private-Package: Coffee I'm running 2.0.0REL with Eclipse
	 * Juno.
	 */
public static void testUpperCasePackage() throws Exception {
    Builder b = new Builder();
    try {
        b.addClasspath(IO.getFile("bin"));
        b.setExportPackage("UPPERCASEPACKAGE");
        b.build();
        assertTrue(b.check());
        b.getExports().containsFQN("UPPERCASEPACKAGE");
    } finally {
        b.close();
    }
}
Also used : Builder(aQute.bnd.osgi.Builder)

Aggregations

Builder (aQute.bnd.osgi.Builder)440 Jar (aQute.bnd.osgi.Jar)228 File (java.io.File)203 Properties (java.util.Properties)99 Manifest (java.util.jar.Manifest)99 Resource (aQute.bnd.osgi.Resource)83 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 ProjectBuilder (aQute.bnd.build.ProjectBuilder)16 Domain (aQute.bnd.osgi.Domain)16 ArrayList (java.util.ArrayList)14 DependencyGraphBuilder (org.apache.maven.shared.dependency.graph.DependencyGraphBuilder)13 HashMap (java.util.HashMap)12 Project (aQute.bnd.build.Project)10