use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class BuilderTest method testResourceNotFound.
/**
* Test Resource inclusion that do not exist
*
* @throws Exception
*/
public static void testResourceNotFound() throws Exception {
Properties base = new Properties();
base.put(Analyzer.EXPORT_PACKAGE, "*;x-test:=true");
base.put(Analyzer.INCLUDE_RESOURCE, "does_not_exist");
Builder analyzer = new Builder();
try {
analyzer.setClasspath(new File[] { IO.getFile("jar/asm.jar") });
analyzer.setProperties(base);
analyzer.build();
assertTrue(analyzer.check("file does not exist: does_not_exist"));
} finally {
analyzer.close();
}
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ClassParserTest method testUnacceptableReference.
/**
* Included an aop alliance class that is not directly referenced.
*/
public static void testUnacceptableReference() throws Exception {
Builder b = new Builder();
b.addClasspath(IO.getFile("jar/nl.fuji.general.jar"));
b.addClasspath(IO.getFile("jar/spring.jar"));
b.setProperty("Export-Package", "nl.fuji.log");
b.build();
assertFalse(b.getImports().getByFQN("org.aopalliance.aop") != null);
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ClassParserTest method testJQuantlib.
/**
* @Neil: I'm trying to use bnd to bundleize a library called JQuantLib, but
* it causes an ArrayIndexOutOfBoundsException while parsing a class.
* The problem is reproducible and I have even rebuilt the library
* from source and get the same problem. Here's the stack trace:
* java.lang.ArrayIndexOutOfBoundsException: -29373 at
* aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:262) at
* aQute.bnd.osgi.Clazz.<init>(Clazz.java:101) at
* aQute.bnd.osgi.Analyzer.analyzeJar(Analyzer.java:1647) at
* aQute.bnd.osgi.Analyzer.analyzeBundleClasspath(Analyzer.java:1563)
* at aQute.bnd.osgi.Analyzer.analyze(Analyzer.java:108) at
* aQute.bnd.osgi.Builder.analyze(Builder.java:192) at
* aQute.bnd.osgi.Builder.doConditional(Builder.java:158) at
* aQute.bnd.osgi.Builder.build(Builder.java:71) at
* aQute.bnd.main.bnd.doBuild(bnd.java:379) at
* aQute.bnd.main.bnd.run(bnd.java:130) at
* aQute.bnd.main.bnd.main(bnd.java:39)
* @throws Exception
*/
public static void testJQuantlib() throws Exception {
Builder b = new Builder();
b.addClasspath(IO.getFile("testresources/jquantlib-0.1.2.jar"));
b.setProperty("Export-Package", "*");
b.build();
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class ProjectTest method testGetOutputFile.
/**
* Check that the output property can be used to name the output binary.
*/
public void testGetOutputFile() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project top = ws.getProject("p1");
//
// We expect p1 to be a single project (no sub builders)
//
assertEquals("p1 must be singleton", 1, top.getSubBuilders().size());
Builder builder = top.getSubBuilders().iterator().next();
assertEquals("p1 must be singleton", "p1", builder.getBsn());
// Check the default bsn.jar form
assertEquals(new File(top.getTarget(), "p1.jar"), top.getOutputFile("p1"));
assertEquals(new File(top.getTarget(), "p1.jar"), top.getOutputFile("p1", "0"));
// Add the version to the filename
top.setProperty("-outputmask", "${@bsn}-${version;===s;${@version}}.jar");
assertEquals(new File(top.getTarget(), "p1-1.260.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
top.setProperty("Bundle-Version", "1.260.0.SNAPSHOT");
assertEquals(new File(top.getTarget(), "p1-1.260.0-SNAPSHOT.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
top.setProperty("-outputmask", "${@bsn}-${version;===S;${@version}}.jar");
assertEquals(new File(top.getTarget(), "p1-1.260.0-SNAPSHOT.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
top.setProperty("Bundle-Version", "1.260.0.NOTSNAPSHOT");
top.setProperty("-outputmask", "${@bsn}-${version;===S;${@version}}.jar");
assertEquals(new File(top.getTarget(), "p1-1.260.0.NOTSNAPSHOT.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
top.setProperty("-outputmask", "${@bsn}-${version;===s;${@version}}.jar");
assertEquals(new File(top.getTarget(), "p1-1.260.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
top.setProperty("Bundle-Version", "42");
top.setProperty("-outputmask", "${@bsn}-${version;===S;${@version}}.jar");
assertEquals(new File(top.getTarget(), "p1-42.0.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
top.setProperty("-outputmask", "${@bsn}-${version;===s;${@version}}.jar");
assertEquals(new File(top.getTarget(), "p1-42.0.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class UsesTest method checkUses.
private static void checkUses(String export, String uses) throws IOException, Exception {
Builder a = new Builder();
a.addClasspath(new File("bin"));
a.setExportPackage(export);
a.setProperty("build", "123");
Jar jar = a.build();
assertTrue(a.check());
Manifest m = jar.getManifest();
m.write(System.err);
Domain d = Domain.domain(m);
Parameters parameters = d.getExportPackage();
Attrs attrs = parameters.get(export);
assertNotNull(attrs);
assertEquals(uses, attrs.get("uses:"));
}
Aggregations