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();
}
}
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();
}
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)\""));
}
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
}
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;
}
Aggregations