use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ClazzTest method testJiniPlatformClasses.
/**
* <pre>
* java.lang.ArrayIndexOutOfBoundsException: 43007 [bnd] at
* aQute.bnd.osgi.Clazz.classConstRef(Clazz.java:1880) [bnd] at
* aQute.bnd.osgi.Clazz.crawl(Clazz.java:1185)
* </pre>
*
* This happened on the Jini platform
*
* @throws Exception
*/
public void testJiniPlatformClasses() throws Exception {
try (Builder b = new Builder()) {
b.addClasspath(IO.getFile("jar/jsk-platform.jar"));
b.setExportPackage("*");
Jar build = b.build();
assertTrue(b.check());
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testMetaInfExport.
/**
* Check if we export META-INF when we export the complete classpath.
*/
public static void testMetaInfExport() throws Exception {
Properties base = new Properties();
base.put(Analyzer.EXPORT_PACKAGE, "*");
Builder analyzer = new Builder();
try {
analyzer.setClasspath(new File[] { IO.getFile("jar/asm.jar") });
analyzer.setProperties(base);
analyzer.build();
assertTrue(analyzer.check());
assertFalse(analyzer.getExports().getByFQN("META-INF") != null);
assertTrue(analyzer.getExports().getByFQN("org.objectweb.asm") != null);
} finally {
analyzer.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method test1017UsingPrivatePackagesVersion.
/**
* #1017 Wrong import version range being generated On one project I depend
* on bundle A and bundle B. Both only export packages in version 1.0. No
* package is exported by both of them. But B also embeds one package from A
* in version 2.0 (via
* http://njbartlett.name/2014/05/26/static-linking.html) but that one
* package is not exported from B. Now if the classpath first contains B
* then A the import-package statement being generated for that package
* (being embedded in B in version 2.0 and exported from A in 1.0) has a
* version range starting with 2.0 (which is wrong). Only if the classpath
* contains A first and then B, it takes the right import version range for
* that package (namely starting with 1.0) I use the maven-bundle-plugin
* 2.5.3 with bndlib 2.4.0.
*/
public void test1017UsingPrivatePackagesVersion() throws Exception {
Builder A = new Builder();
A.addClasspath(new File("jar/osgi.jar"));
A.setExportPackage("org.osgi.service.event");
A.build();
assertTrue(A.check());
Builder B = new Builder();
B.addClasspath(new File("jar/osgi.jar"));
B.setExportPackage("org.osgi.service.wireadmin");
B.setPrivatePackage("org.osgi.service.event");
B.setIncludeResource("org/osgi/service/event/packageinfo;literal='version 2.0.0'");
B.build();
assertTrue(B.check());
Builder B_A = new Builder();
B_A.addClasspath(B.getJar());
B_A.addClasspath(A.getJar());
B_A.addClasspath(new File("bin"));
B_A.setPrivatePackage("test.reference_to_eventadmin");
B_A.build();
assertTrue(B_A.check());
assertEquals("[1.0,2)", B_A.getImports().getByFQN("org.osgi.service.event").getVersion());
Builder A_B = new Builder();
A_B.addClasspath(A.getJar());
A_B.addClasspath(B.getJar());
A_B.addClasspath(new File("bin"));
A_B.setPrivatePackage("test.reference_to_eventadmin");
A_B.build();
assertTrue(A_B.check());
assertEquals("[1.0,2)", A_B.getImports().getByFQN("org.osgi.service.event").getVersion());
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testNoImportDirective.
public static void testNoImportDirective() throws Exception {
Builder b = new Builder();
try {
b.setProperty("Export-Package", "org.osgi.util.measurement, org.osgi.service.http;-noimport:=true");
b.setProperty("Private-Package", "org.osgi.framework, test.refer");
b.addClasspath(IO.getFile("jar/osgi.jar"));
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertTrue(b.check());
Manifest m = jar.getManifest();
String imports = m.getMainAttributes().getValue("Import-Package");
// referred
assertTrue(imports.contains("org.osgi.util.measurement"));
// to
// but
// no
// private
// references
// (does
// not
// use
// fw).
// referred
assertFalse(imports.contains("org.osgi.service.http"));
// to
// but no
// private
// references
// (does not
// use
// fw).
} finally {
b.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testBundleClasspath.
public static void testBundleClasspath() throws Exception {
Builder bmaker = new Builder();
try {
Properties p = new Properties();
p.put("Export-Package", "test.activator;-split-package:=merge-first");
p.put("Bundle-Activator", "test.activator.Activator");
p.put("Import-Package", "*");
p.put("Bundle-ClassPath", ".");
bmaker.setProperties(p);
bmaker.setClasspath(new File[] { new File("bin"), new File("src") });
Jar jar = bmaker.build();
assertTrue(bmaker.check());
report("testBundleClasspath", bmaker, jar);
jar.exists("testresources/activator/Activator.class");
assertEquals(bmaker.getErrors().size(), 0);
assertEquals(bmaker.getWarnings().size(), 0);
} finally {
bmaker.close();
}
}
Aggregations