} catch (MalformedURLException e) {
// Ignore it.
}
}
TinyBundle tested = TinyBundles.bundle();
// We look inside target/classes to find the class and resources
File classes = new File("target/classes");
Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
List<String> exports = new ArrayList<String>();
for (File file : files) {
if (file.isDirectory()) {
// By convention we export of .services and .service package
if (file.getAbsolutePath().contains("/services") || file.getAbsolutePath().contains("/service")) {
String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
String packageName = path.replace('/', '.');
exports.add(packageName);
}
} else {
// We need to compute the path
String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
try {
tested.add(path, file.toURI().toURL());
} catch (MalformedURLException e) {
// Ignore it.
}
System.out.println(file.getName() + " added to " + path);
}
}
// Depending on the the order, the probe bundle may already have detected requirements on components.
String clause = "" +
"org.apache.felix.ipojo.runtime.core.components, " +
"org.apache.felix.ipojo.runtime.core.services, " +
"org.apache.felix.ipojo.runtime.core.services.A123";
for (String export : exports) {
if (export.length() > 0) { export += ", "; }
clause += export;
}
System.out.println("Exported packages : " + clause);
InputStream inputStream = tested
.set(Constants.BUNDLE_SYMBOLICNAME, BaseTest.TEST_BUNDLE_SYMBOLIC_NAME + "-with-native")
.set(Constants.IMPORT_PACKAGE, "*")
.set(Constants.EXPORT_PACKAGE, clause)
.set(Constants.BUNDLE_NATIVECODE, NATIVE_CLAUSE)
.build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));