Search in sources :

Example 11 with Packages

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

the class BuilderTest method assertVersionEquals.

static void assertVersionEquals(String input, String output) throws Exception {
    File[] cp = { IO.getFile("jar/osgi.jar") };
    Builder bmaker = new Builder();
    try {
        bmaker.setClasspath(cp);
        Properties p = new Properties();
        p.put(Analyzer.EXPORT_PACKAGE, "test.activator");
        p.put(Analyzer.IMPORT_PACKAGE, "org.osgi.framework;version=\"" + input + "\"");
        bmaker.setProperties(p);
        bmaker.build();
        assertTrue(bmaker.check("The JAR is empty"));
        Packages imports = bmaker.getImports();
        Map<String, String> framework = imports.get(bmaker.getPackageRef("org.osgi.framework"));
        assertEquals(output, framework.get("version"));
    } finally {
        bmaker.close();
    }
}
Also used : Packages(aQute.bnd.osgi.Packages) Builder(aQute.bnd.osgi.Builder) Properties(java.util.Properties) File(java.io.File)

Example 12 with Packages

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

the class BuilderTest method testImportRangeCalculatedFromClasspath_4.

/**
	 * Check if we imported the package with the correct version range when
	 * there's an empty package in front of it in the classpath. Second form
	 * calling builds().
	 */
public static void testImportRangeCalculatedFromClasspath_4() throws Exception {
    Properties base = new Properties();
    base.put(Analyzer.IMPORT_PACKAGE, "javax.servlet,javax.servlet.http");
    String pwd = System.getProperty("user.dir");
    base.put("pwd", new File(pwd).toURI().toString());
    base.put("-classpath", "${pwd}/jar/jsp-api.jar,${pwd}/jar/servlet-api.jar");
    Builder analyzer = new Builder();
    try {
        analyzer.addClasspath(new File("bin"));
        analyzer.setPrivatePackage("test");
        analyzer.setProperties(base);
        analyzer.builds();
        assertTrue(analyzer.check());
        Packages imports = analyzer.getImports();
        Attrs attrs = imports.getByFQN("javax.servlet.http");
        assertEquals("[3.0,4)", attrs.getVersion());
        attrs = imports.getByFQN("javax.servlet");
        assertEquals("[3.0,4)", attrs.getVersion());
    } finally {
        analyzer.close();
    }
}
Also used : Packages(aQute.bnd.osgi.Packages) Builder(aQute.bnd.osgi.Builder) Attrs(aQute.bnd.header.Attrs) Properties(java.util.Properties) File(java.io.File)

Aggregations

Packages (aQute.bnd.osgi.Packages)12 Builder (aQute.bnd.osgi.Builder)9 Attrs (aQute.bnd.header.Attrs)7 File (java.io.File)7 Properties (java.util.Properties)7 Analyzer (aQute.bnd.osgi.Analyzer)4 Jar (aQute.bnd.osgi.Jar)4 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)3 Parameters (aQute.bnd.header.Parameters)2 Domain (aQute.bnd.osgi.Domain)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Manifest (java.util.jar.Manifest)2 PomFromManifest (aQute.bnd.maven.PomFromManifest)1 Def (aQute.bnd.osgi.Clazz.Def)1 Descriptors (aQute.bnd.osgi.Descriptors)1 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)1 FileResource (aQute.bnd.osgi.FileResource)1 Resource (aQute.bnd.osgi.Resource)1 Verifier (aQute.bnd.osgi.Verifier)1 AnalyzerPlugin (aQute.bnd.service.AnalyzerPlugin)1